Merge pull request #1696 from owncloud/initialization-responsibility

This commit is contained in:
Alex Unger
2021-02-24 14:10:57 +01:00
committed by GitHub
16 changed files with 386 additions and 338 deletions
+2
View File
@@ -7,6 +7,8 @@ require (
contrib.go.opencensus.io/exporter/ocagent v0.6.0
contrib.go.opencensus.io/exporter/zipkin v0.1.1
github.com/asim/go-micro/plugins/client/grpc/v3 v3.0.0-20210217182006-0f0ace1a44a9
github.com/asim/go-micro/plugins/registry/kubernetes/v3 v3.0.0-20210217182006-0f0ace1a44a9 // indirect
github.com/asim/go-micro/plugins/registry/nats/v3 v3.0.0-20210217182006-0f0ace1a44a9 // indirect
github.com/asim/go-micro/v3 v3.5.1-0.20210217182006-0f0ace1a44a9
github.com/cs3org/go-cs3apis v0.0.0-20210209082852-35ace33082f5
github.com/cs3org/reva v1.6.1-0.20210223065028-53f39499762e
-3
View File
@@ -160,9 +160,6 @@ func Server(cfg *config.Config) *cli.Command {
)
gr.Add(func() error {
logger.Info().Str("service", server.Name()).Msg("Reporting settings bundles to settings service")
svc.RegisterSettingsBundles(&logger)
svc.RegisterPermissions(&logger)
return server.Run()
}, func(_ error) {
logger.Info().
+29 -27
View File
@@ -10,6 +10,8 @@ import (
"path/filepath"
"testing"
mgrpcc "github.com/asim/go-micro/plugins/client/grpc/v3"
"github.com/asim/go-micro/v3/client"
merrors "github.com/asim/go-micro/v3/errors"
"github.com/golang/protobuf/ptypes/empty"
@@ -24,7 +26,7 @@ import (
"google.golang.org/protobuf/types/known/timestamppb"
)
var service = grpc.Service{}
var service = grpc.NewService()
var dataPath = createTmpDir()
@@ -313,7 +315,7 @@ func assertGroupHasMember(t *testing.T, grp *proto.Group, memberId string) {
}
func createAccount(t *testing.T, user string) (*proto.Account, error) {
client := service.Client()
client := mgrpcc.NewClient()
cl := proto.NewAccountsService("com.owncloud.api.accounts", client)
account := getAccount(user)
@@ -326,7 +328,7 @@ func createAccount(t *testing.T, user string) (*proto.Account, error) {
}
func createGroup(t *testing.T, group *proto.Group) (*proto.Group, error) {
client := service.Client()
client := mgrpcc.NewClient()
cl := proto.NewGroupsService("com.owncloud.api.accounts", client)
request := &proto.CreateGroupRequest{Group: group}
@@ -338,7 +340,7 @@ func createGroup(t *testing.T, group *proto.Group) (*proto.Group, error) {
}
func updateAccount(t *testing.T, account *proto.Account, updateArray []string) (*proto.Account, error) {
client := service.Client()
client := mgrpcc.NewClient()
cl := proto.NewAccountsService("com.owncloud.api.accounts", client)
updateMask := &field_mask.FieldMask{
@@ -352,7 +354,7 @@ func updateAccount(t *testing.T, account *proto.Account, updateArray []string) (
func listAccounts(t *testing.T) (*proto.ListAccountsResponse, error) {
request := &proto.ListAccountsRequest{}
client := service.Client()
client := mgrpcc.NewClient()
cl := proto.NewAccountsService("com.owncloud.api.accounts", client)
response, err := cl.ListAccounts(context.Background(), request)
@@ -361,7 +363,7 @@ func listAccounts(t *testing.T) (*proto.ListAccountsResponse, error) {
func listGroups(t *testing.T) *proto.ListGroupsResponse {
request := &proto.ListGroupsRequest{}
client := service.Client()
client := mgrpcc.NewClient()
cl := proto.NewGroupsService("com.owncloud.api.accounts", client)
response, err := cl.ListGroups(context.Background(), request)
@@ -370,7 +372,7 @@ func listGroups(t *testing.T) *proto.ListGroupsResponse {
}
func deleteAccount(t *testing.T, id string) (*empty.Empty, error) {
client := service.Client()
client := mgrpcc.NewClient()
cl := proto.NewAccountsService("com.owncloud.api.accounts", client)
req := &proto.DeleteAccountRequest{Id: id}
@@ -379,7 +381,7 @@ func deleteAccount(t *testing.T, id string) (*empty.Empty, error) {
}
func deleteGroup(t *testing.T, id string) (*empty.Empty, error) {
client := service.Client()
client := mgrpcc.NewClient()
cl := proto.NewGroupsService("com.owncloud.api.accounts", client)
req := &proto.DeleteGroupRequest{Id: id}
@@ -767,7 +769,7 @@ func TestDeleteAccount(t *testing.T) {
req := &proto.DeleteAccountRequest{Id: getAccount("user1").Id}
client := service.Client()
client := mgrpcc.NewClient()
cl := proto.NewAccountsService("com.owncloud.api.accounts", client)
resp, err := cl.DeleteAccount(context.Background(), req)
@@ -785,7 +787,7 @@ func TestDeleteAccount(t *testing.T) {
func TestListGroups(t *testing.T) {
req := &proto.ListGroupsRequest{}
client := service.Client()
client := mgrpcc.NewClient()
cl := proto.NewGroupsService("com.owncloud.api.accounts", client)
resp, err := cl.ListGroups(context.Background(), req)
@@ -812,7 +814,7 @@ func TestListGroups(t *testing.T) {
}
func TestGetGroups(t *testing.T) {
client := service.Client()
client := mgrpcc.NewClient()
cl := proto.NewGroupsService("com.owncloud.api.accounts", client)
groups := []string{
@@ -860,7 +862,7 @@ func TestCreateGroup(t *testing.T) {
}
func TestGetGroupInvalidID(t *testing.T) {
client := service.Client()
client := mgrpcc.NewClient()
cl := proto.NewGroupsService("com.owncloud.api.accounts", client)
req := &proto.GetGroupRequest{Id: "42"}
@@ -880,7 +882,7 @@ func TestDeleteGroup(t *testing.T) {
createGroup(t, grp2)
createGroup(t, grp3)
client := service.Client()
client := mgrpcc.NewClient()
cl := proto.NewGroupsService("com.owncloud.api.accounts", client)
req := &proto.DeleteGroupRequest{Id: grp1.Id}
@@ -909,7 +911,7 @@ func TestDeleteGroupNotExisting(t *testing.T) {
" ",
}
client := service.Client()
client := mgrpcc.NewClient()
cl := proto.NewGroupsService("com.owncloud.api.accounts", client)
for _, id := range invalidIds {
@@ -932,7 +934,7 @@ func TestDeleteGroupInvalidId(t *testing.T) {
"": ".",
}
client := service.Client()
client := mgrpcc.NewClient()
cl := proto.NewGroupsService("com.owncloud.api.accounts", client)
for id := range invalidIds {
@@ -949,7 +951,7 @@ func TestUpdateGroup(t *testing.T) {
grp1 := getTestGroups("grp1")
createGroup(t, grp1)
client := service.Client()
client := mgrpcc.NewClient()
cl := proto.NewGroupsService("com.owncloud.api.accounts", client)
updateGrp := &proto.Group{
@@ -978,7 +980,7 @@ func TestAddMember(t *testing.T) {
createGroup(t, grp1)
createAccount(t, account.PreferredName)
client := service.Client()
client := mgrpcc.NewClient()
cl := proto.NewGroupsService("com.owncloud.api.accounts", client)
req := &proto.AddMemberRequest{GroupId: grp1.Id, AccountId: account.Id}
@@ -1010,7 +1012,7 @@ func TestAddMemberAlreadyInGroup(t *testing.T) {
addMemberToGroup(t, grp1.Id, account.Id)
client := service.Client()
client := mgrpcc.NewClient()
cl := proto.NewGroupsService("com.owncloud.api.accounts", client)
req := &proto.AddMemberRequest{GroupId: grp1.Id, AccountId: account.Id}
@@ -1035,7 +1037,7 @@ func TestAddMemberNonExisting(t *testing.T) {
createGroup(t, grp1)
client := service.Client()
client := mgrpcc.NewClient()
cl := proto.NewGroupsService("com.owncloud.api.accounts", client)
invalidIds := []string{
@@ -1063,7 +1065,7 @@ func TestAddMemberNonExisting(t *testing.T) {
}
func addMemberToGroup(t *testing.T, groupId, memberId string) (*proto.Group, error) {
client := service.Client()
client := mgrpcc.NewClient()
cl := proto.NewGroupsService("com.owncloud.api.accounts", client)
req := &proto.AddMemberRequest{GroupId: groupId, AccountId: memberId}
@@ -1083,7 +1085,7 @@ func TestRemoveMember(t *testing.T) {
addMemberToGroup(t, grp1.Id, account.Id)
client := service.Client()
client := mgrpcc.NewClient()
cl := proto.NewGroupsService("com.owncloud.api.accounts", client)
req := &proto.RemoveMemberRequest{GroupId: grp1.Id, AccountId: account.Id}
@@ -1106,7 +1108,7 @@ func TestRemoveMemberNonExistingUser(t *testing.T) {
createGroup(t, grp1)
client := service.Client()
client := mgrpcc.NewClient()
cl := proto.NewGroupsService("com.owncloud.api.accounts", client)
invalidIds := []string{
@@ -1140,7 +1142,7 @@ func TestRemoveMemberNotInGroup(t *testing.T) {
createGroup(t, grp1)
createAccount(t, account.PreferredName)
client := service.Client()
client := mgrpcc.NewClient()
cl := proto.NewGroupsService("com.owncloud.api.accounts", client)
req := &proto.RemoveMemberRequest{GroupId: grp1.Id, AccountId: account.Id}
@@ -1177,7 +1179,7 @@ func TestListMembers(t *testing.T) {
"physics-lovers",
}
client := service.Client()
client := mgrpcc.NewClient()
cl := proto.NewGroupsService("com.owncloud.api.accounts", client)
for _, group := range groups {
@@ -1209,7 +1211,7 @@ func TestListMembers(t *testing.T) {
func TestListMembersEmptyGroup(t *testing.T) {
group := &proto.Group{Id: "5d58e5ec-842e-498b-8800-61f2ec6f911c", GidNumber: 60000, OnPremisesSamAccountName: "quantum-group", DisplayName: "Quantum Group", Members: []*proto.Account{}}
client := service.Client()
client := mgrpcc.NewClient()
cl := proto.NewGroupsService("com.owncloud.api.accounts", client)
request := &proto.CreateGroupRequest{Group: group}
@@ -1231,7 +1233,7 @@ func TestListMembersEmptyGroup(t *testing.T) {
func TestAccountUpdateMask(t *testing.T) {
createAccount(t, "user1")
user1 := getAccount("user1")
client := service.Client()
client := mgrpcc.NewClient()
req := &proto.UpdateAccountRequest{
// We only want to update the display-name, rest should be ignored
UpdateMask: &field_mask.FieldMask{Paths: []string{"DisplayName"}},
@@ -1254,7 +1256,7 @@ func TestAccountUpdateMask(t *testing.T) {
func TestAccountUpdateReadOnlyField(t *testing.T) {
createAccount(t, "user1")
user1 := getAccount("user1")
client := service.Client()
client := mgrpcc.NewClient()
req := &proto.UpdateAccountRequest{
// We only want to update the display-name, rest should be ignored
UpdateMask: &field_mask.FieldMask{Paths: []string{"CreatedDateTime"}},
+27 -33
View File
@@ -19,9 +19,9 @@ import (
"github.com/owncloud/ocis/accounts/pkg/config"
"github.com/owncloud/ocis/accounts/pkg/proto/v0"
"github.com/owncloud/ocis/ocis-pkg/log"
oreg "github.com/owncloud/ocis/ocis-pkg/registry"
"github.com/owncloud/ocis/ocis-pkg/roles"
settings "github.com/owncloud/ocis/settings/pkg/proto/v0"
settings_svc "github.com/owncloud/ocis/settings/pkg/service/v0"
)
// userDefaultGID is the default integer representing the "users" group.
@@ -57,6 +57,31 @@ func New(opts ...Option) (s *Service, err error) {
repo: createMetadataStorage(cfg, logger),
}
retries := 20
var current int
r := oreg.GetRegistry()
if cfg.Repo.Disk.Path == "" {
for {
if current >= retries {
panic("metadata service failed to start.")
}
s, err := r.GetService("com.owncloud.storage.metadata")
if err != nil {
logger.Error().Err(err).Msg("error getting metadata service from service registry")
}
if len(s) > 0 {
break
}
logger.Info().Msg("accounts blocked waiting for metadata service to be up and running...")
time.Sleep(2 * time.Second)
current++
}
}
// we want to wait anyway. If it depends on a reva service it could be the case that the entry on the registry
// happens prior to the reva service being up and running
time.Sleep(500 * time.Millisecond)
if s.index, err = s.buildIndex(); err != nil {
return nil, err
}
@@ -68,7 +93,6 @@ func New(opts ...Option) (s *Service, err error) {
if err = s.createDefaultGroups(); err != nil {
return nil, err
}
// TODO watch folders for new records
return
}
@@ -267,6 +291,7 @@ func (s Service) createDefaultAccounts() (err error) {
},
},
}
// this only deals with the metadata service.
for i := range accounts {
a := &proto.Account{}
err := s.repo.LoadAccount(context.Background(), accounts[i].Id, a)
@@ -287,7 +312,6 @@ func (s Service) createDefaultAccounts() (err error) {
}
}
// TODO: can be removed again as soon as we respect the predefined UIDs and GIDs from the account. Then no autoincrement is happening, therefore we don't need to update accounts.
changed := false
for _, r := range results {
if r.Field == "UidNumber" || r.Field == "GidNumber" {
@@ -309,24 +333,6 @@ func (s Service) createDefaultAccounts() (err error) {
}
}
}
// set role for admin users and regular users
assignRoleToUser("058bff95-6708-4fe5-91e4-9ea3d377588b", settings_svc.BundleUUIDRoleAdmin, s.RoleService, s.log)
for _, accountID := range []string{
"058bff95-6708-4fe5-91e4-9ea3d377588b", //moss
"ddc2004c-0977-11eb-9d3f-a793888cd0f8", //admin
"820ba2a1-3f54-4538-80a4-2d73007e30bf", //idp
"bc596f3c-c955-4328-80a0-60d018b4ad57", //reva
} {
assignRoleToUser(accountID, settings_svc.BundleUUIDRoleAdmin, s.RoleService, s.log)
}
for _, accountID := range []string{
"4c510ada-c86b-4815-8820-42cdf82c3d51", //einstein
"f7fbf8c8-139b-4376-b307-cf0a8c2d0d9c", //marie
"932b4540-8d16-481e-8ef4-588e4b6b151c", //richard
} {
assignRoleToUser(accountID, settings_svc.BundleUUIDRoleUser, s.RoleService, s.log)
}
return nil
}
@@ -403,18 +409,6 @@ func (s Service) createDefaultGroups() (err error) {
return nil
}
func assignRoleToUser(accountID, roleID string, rs settings.RoleService, logger log.Logger) (ok bool) {
_, err := rs.AssignRoleToUser(context.Background(), &settings.AssignRoleToUserRequest{
AccountUuid: accountID,
RoleId: roleID,
})
if err != nil {
logger.Error().Err(err).Str("accountID", accountID).Str("roleID", roleID).Msg("could not set role for account")
return false
}
return true
}
func createMetadataStorage(cfg *config.Config, logger log.Logger) storage.Repo {
// for now we detect the used storage implementation based on which storage is configured
// the config with defaults needs to be checked last
-194
View File
@@ -1,194 +0,0 @@
package service
import (
"context"
olog "github.com/owncloud/ocis/ocis-pkg/log"
"github.com/owncloud/ocis/ocis-pkg/service/grpc"
settings "github.com/owncloud/ocis/settings/pkg/proto/v0"
ssvc "github.com/owncloud/ocis/settings/pkg/service/v0"
)
const (
settingUUIDProfileLanguage = "aa8cfbe5-95d4-4f7e-a032-c3c01f5f062f"
)
// RegisterSettingsBundles pushes the settings bundle definitions for this extension to the ocis-settings service.
func RegisterSettingsBundles(l *olog.Logger) {
service := settings.NewBundleService("com.owncloud.api.settings", grpc.DefaultClient)
bundleRequests := []settings.SaveBundleRequest{
generateBundleProfileRequest(),
}
for i := range bundleRequests {
res, err := service.SaveBundle(context.Background(), &bundleRequests[i])
if err != nil {
l.Err(err).Str("bundle", bundleRequests[i].Bundle.Id).Msg("Error registering bundle")
} else {
l.Info().Str("bundle", res.Bundle.Id).Msg("Successfully registered bundle")
}
}
permissionRequests := generateProfilePermissionsRequests()
for i := range permissionRequests {
res, err := service.AddSettingToBundle(context.Background(), &permissionRequests[i])
bundleID := permissionRequests[i].BundleId
if err != nil {
l.Err(err).Str("bundle", bundleID).Str("setting", permissionRequests[i].Setting.Id).Msg("Error adding setting to bundle")
} else {
l.Info().Str("bundle", bundleID).Str("setting", res.Setting.Id).Msg("Successfully added setting to bundle")
}
}
}
var languageSetting = settings.Setting_SingleChoiceValue{
SingleChoiceValue: &settings.SingleChoiceList{
Options: []*settings.ListOption{
{
Value: &settings.ListOptionValue{
Option: &settings.ListOptionValue_StringValue{
StringValue: "cs",
},
},
DisplayValue: "Czech",
},
{
Value: &settings.ListOptionValue{
Option: &settings.ListOptionValue_StringValue{
StringValue: "de",
},
},
DisplayValue: "Deutsch",
},
{
Value: &settings.ListOptionValue{
Option: &settings.ListOptionValue_StringValue{
StringValue: "en",
},
},
DisplayValue: "English",
},
{
Value: &settings.ListOptionValue{
Option: &settings.ListOptionValue_StringValue{
StringValue: "es",
},
},
DisplayValue: "Español",
},
{
Value: &settings.ListOptionValue{
Option: &settings.ListOptionValue_StringValue{
StringValue: "fr",
},
},
DisplayValue: "Français",
},
{
Value: &settings.ListOptionValue{
Option: &settings.ListOptionValue_StringValue{
StringValue: "gl",
},
},
DisplayValue: "Galego",
},
{
Value: &settings.ListOptionValue{
Option: &settings.ListOptionValue_StringValue{
StringValue: "it",
},
},
DisplayValue: "Italiano",
},
},
},
}
func generateBundleProfileRequest() settings.SaveBundleRequest {
return settings.SaveBundleRequest{
Bundle: &settings.Bundle{
Id: "2a506de7-99bd-4f0d-994e-c38e72c28fd9",
Name: "profile",
Extension: "ocis-accounts",
Type: settings.Bundle_TYPE_DEFAULT,
Resource: &settings.Resource{
Type: settings.Resource_TYPE_SYSTEM,
},
DisplayName: "Profile",
Settings: []*settings.Setting{
{
Id: settingUUIDProfileLanguage,
Name: "language",
DisplayName: "Language",
Description: "User language",
Resource: &settings.Resource{
Type: settings.Resource_TYPE_USER,
},
Value: &languageSetting,
},
},
},
}
}
func generateProfilePermissionsRequests() []settings.AddSettingToBundleRequest {
// TODO: we don't want to set up permissions for settings manually in the future. Instead each setting should come with
// a set of default permissions for the default roles (guest, user, admin).
return []settings.AddSettingToBundleRequest{
{
BundleId: ssvc.BundleUUIDRoleAdmin,
Setting: &settings.Setting{
Id: "7d81f103-0488-4853-bce5-98dcce36d649",
Name: "language-readwrite",
DisplayName: "Permission to read and set the language (anyone)",
Resource: &settings.Resource{
Type: settings.Resource_TYPE_SETTING,
Id: settingUUIDProfileLanguage,
},
Value: &settings.Setting_PermissionValue{
PermissionValue: &settings.Permission{
Operation: settings.Permission_OPERATION_READWRITE,
Constraint: settings.Permission_CONSTRAINT_ALL,
},
},
},
},
{
BundleId: ssvc.BundleUUIDRoleUser,
Setting: &settings.Setting{
Id: "640e00d2-4df8-41bd-b1c2-9f30a01e0e99",
Name: "language-readwrite",
DisplayName: "Permission to read and set the language (self)",
Resource: &settings.Resource{
Type: settings.Resource_TYPE_SETTING,
Id: settingUUIDProfileLanguage,
},
Value: &settings.Setting_PermissionValue{
PermissionValue: &settings.Permission{
Operation: settings.Permission_OPERATION_READWRITE,
Constraint: settings.Permission_CONSTRAINT_OWN,
},
},
},
},
{
BundleId: ssvc.BundleUUIDRoleGuest,
Setting: &settings.Setting{
Id: "ca878636-8b1a-4fae-8282-8617a4c13597",
Name: "language-readwrite",
DisplayName: "Permission to read and set the language (self)",
Resource: &settings.Resource{
Type: settings.Resource_TYPE_SETTING,
Id: settingUUIDProfileLanguage,
},
Value: &settings.Setting_PermissionValue{
PermissionValue: &settings.Permission{
Operation: settings.Permission_OPERATION_READWRITE,
Constraint: settings.Permission_CONSTRAINT_OWN,
},
},
},
},
}
}
@@ -0,0 +1,11 @@
Bugfix: Fix accounts initialization
Originally the accounts service relies on both the `settings` and `storage-metadata` to be up and running at the moment it starts. This is an antipattern as it will cause the entire service to panic if the dependants are not present.
We inverted this dependency and moved the default initialization data (i.e: creating roles, permissions, settings bundles) and instead of notifying the settings service that the account has to provide with such options, the settings is instead initialized with the options the accounts rely on. Essentially saving bandwith as there is no longer a gRPC call to the settings service.
For the `storage-metadata` a retry mechanism was added that retries by default 20 times to fetch the `com.owncloud.storage.metadata` from the service registry every `500` miliseconds. If this retry expires the accounts panics, as its dependency on the `storage-metadata` service cannot be resolved.
We also introduced a client wrapper that acts as middleware between a client and a server. For more information on how it works further read [here](https://github.com/sony/gobreaker)
https://github.com/owncloud/ocis/pull/1696
+2
View File
@@ -12,6 +12,7 @@ require (
github.com/asim/go-micro/plugins/registry/nats/v3 v3.0.0-20210217182006-0f0ace1a44a9
github.com/asim/go-micro/plugins/server/grpc/v3 v3.0.0-20210217182006-0f0ace1a44a9
github.com/asim/go-micro/plugins/server/http/v3 v3.0.0-20210217182006-0f0ace1a44a9
github.com/asim/go-micro/plugins/wrapper/breaker/gobreaker/v3 v3.0.0-20210217182006-0f0ace1a44a9
github.com/asim/go-micro/plugins/wrapper/monitoring/prometheus/v3 v3.0.0-20210217182006-0f0ace1a44a9
github.com/asim/go-micro/plugins/wrapper/trace/opencensus/v3 v3.0.0-20210217182006-0f0ace1a44a9
github.com/asim/go-micro/v3 v3.5.1-0.20210217182006-0f0ace1a44a9
@@ -29,6 +30,7 @@ require (
github.com/prometheus/client_golang v1.7.1
github.com/restic/calens v0.2.0
github.com/rs/zerolog v1.20.0
github.com/sony/gobreaker v0.4.1
github.com/stretchr/testify v1.7.0
github.com/tomasen/realip v0.0.0-20180522021738-f0c99a92ddce
go.opencensus.io v0.22.6
+4
View File
@@ -161,6 +161,8 @@ github.com/asim/go-micro/plugins/server/http/v3 v3.0.0-20210217182006-0f0ace1a44
github.com/asim/go-micro/plugins/server/http/v3 v3.0.0-20210217182006-0f0ace1a44a9/go.mod h1:Oe0f4zsBx6if1scvMrL/4mNfkD7URaqkvhQWnWogcws=
github.com/asim/go-micro/plugins/transport/grpc/v3 v3.0.0-20210202145831-070250155285 h1:3YQx0EQbHNYpp1FwnHrgU0oRFISjZvBGL7UhpA8/Nas=
github.com/asim/go-micro/plugins/transport/grpc/v3 v3.0.0-20210202145831-070250155285/go.mod h1:FXWwzJ74gGEIY/gOdDHJqCQuago+tLSkcUPayf9daGM=
github.com/asim/go-micro/plugins/wrapper/breaker/gobreaker/v3 v3.0.0-20210217182006-0f0ace1a44a9 h1:o9Tk3K1WQLOzyEeUBCO+GHO7s9MnzfUT7zLCZ6IzS2g=
github.com/asim/go-micro/plugins/wrapper/breaker/gobreaker/v3 v3.0.0-20210217182006-0f0ace1a44a9/go.mod h1:nAb0ampZ6EieuECEhCoPKjQvGzqRv35uPtvZ/do7dWY=
github.com/asim/go-micro/plugins/wrapper/monitoring/prometheus/v3 v3.0.0-20210217182006-0f0ace1a44a9 h1:divSMUzk92mF5yXK11fAqG/wqQ4Pcal2huJSQm3EwPE=
github.com/asim/go-micro/plugins/wrapper/monitoring/prometheus/v3 v3.0.0-20210217182006-0f0ace1a44a9/go.mod h1:uyEy7qDUtW2lYTnAA9w4hKH+bzotiO1CIm2HHZFn2pg=
github.com/asim/go-micro/plugins/wrapper/trace/opencensus/v3 v3.0.0-20210217182006-0f0ace1a44a9 h1:mX03duCTS0f3et6ZrnKxfh5dNqUIpP8+z+9YSvts8eY=
@@ -1360,6 +1362,8 @@ github.com/smartystreets/goconvey v1.6.4 h1:fv0U8FUIMPNf1L9lnHLvLhgicrIVChEkdzIK
github.com/smartystreets/goconvey v1.6.4/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA=
github.com/soheilhy/cmux v0.1.4 h1:0HKaf1o97UwFjHH9o5XsHUOF+tqmdA7KEzXLpiyaw0E=
github.com/soheilhy/cmux v0.1.4/go.mod h1:IM3LyeVVIOuxMH7sFAkER9+bJ4dT7Ms6E4xg4kGIyLM=
github.com/sony/gobreaker v0.4.1 h1:oMnRNZXX5j85zso6xCPRNPtmAycat+WcoKbklScLDgQ=
github.com/sony/gobreaker v0.4.1/go.mod h1:ZKptC7FHNvhBz7dN2LGjPVBz2sZJmc0/PkyDJOjmxWY=
github.com/sourcegraph/annotate v0.0.0-20160123013949-f4cad6c6324d/go.mod h1:UdhH50NIW0fCiwBSr0co2m7BnFLdv4fQTgdqdJTHFeE=
github.com/sourcegraph/syntaxhighlight v0.0.0-20170531221838-bd320f5d308e/go.mod h1:HuIsMU8RRBOtsCgI77wP899iHVBQpCmg4ErYMZB+2IA=
github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72 h1:qLC7fQah7D6K1B0ujays3HV9gkFtllcxhzImRR7ArPQ=
+10 -2
View File
@@ -6,14 +6,22 @@ import (
mgrpcc "github.com/asim/go-micro/plugins/client/grpc/v3"
mgrpcs "github.com/asim/go-micro/plugins/server/grpc/v3"
mbreaker "github.com/asim/go-micro/plugins/wrapper/breaker/gobreaker/v3"
"github.com/asim/go-micro/plugins/wrapper/monitoring/prometheus/v3"
"github.com/asim/go-micro/plugins/wrapper/trace/opencensus/v3"
"github.com/asim/go-micro/v3"
"github.com/asim/go-micro/v3/client"
"github.com/owncloud/ocis/ocis-pkg/registry"
)
// DefaultClient is a custom ocis grpc configured client.
var DefaultClient = mgrpcc.NewClient()
// DefaultClient is a custom oCIS grpc configured client.
var DefaultClient = getDefaultGrpcClient()
func getDefaultGrpcClient() client.Client {
return mgrpcc.NewClient(
client.Wrap(mbreaker.NewClientWrapper()),
)
}
// Service simply wraps the go-micro grpc service.
type Service struct {
+8 -3
View File
@@ -165,6 +165,8 @@ github.com/asim/go-micro/plugins/server/http/v3 v3.0.0-20210217182006-0f0ace1a44
github.com/asim/go-micro/plugins/server/http/v3 v3.0.0-20210217182006-0f0ace1a44a9/go.mod h1:Oe0f4zsBx6if1scvMrL/4mNfkD7URaqkvhQWnWogcws=
github.com/asim/go-micro/plugins/transport/grpc/v3 v3.0.0-20210202145831-070250155285 h1:3YQx0EQbHNYpp1FwnHrgU0oRFISjZvBGL7UhpA8/Nas=
github.com/asim/go-micro/plugins/transport/grpc/v3 v3.0.0-20210202145831-070250155285/go.mod h1:FXWwzJ74gGEIY/gOdDHJqCQuago+tLSkcUPayf9daGM=
github.com/asim/go-micro/plugins/wrapper/breaker/gobreaker/v3 v3.0.0-20210217182006-0f0ace1a44a9 h1:o9Tk3K1WQLOzyEeUBCO+GHO7s9MnzfUT7zLCZ6IzS2g=
github.com/asim/go-micro/plugins/wrapper/breaker/gobreaker/v3 v3.0.0-20210217182006-0f0ace1a44a9/go.mod h1:nAb0ampZ6EieuECEhCoPKjQvGzqRv35uPtvZ/do7dWY=
github.com/asim/go-micro/plugins/wrapper/monitoring/prometheus/v3 v3.0.0-20210217182006-0f0ace1a44a9 h1:divSMUzk92mF5yXK11fAqG/wqQ4Pcal2huJSQm3EwPE=
github.com/asim/go-micro/plugins/wrapper/monitoring/prometheus/v3 v3.0.0-20210217182006-0f0ace1a44a9/go.mod h1:uyEy7qDUtW2lYTnAA9w4hKH+bzotiO1CIm2HHZFn2pg=
github.com/asim/go-micro/plugins/wrapper/trace/opencensus/v3 v3.0.0-20210217182006-0f0ace1a44a9 h1:mX03duCTS0f3et6ZrnKxfh5dNqUIpP8+z+9YSvts8eY=
@@ -321,6 +323,8 @@ github.com/crewjam/saml v0.4.0/go.mod h1:geQUbAAwmTKNJFDzoXaTssZHY26O89PHIm3K3YW
github.com/cs3org/cato v0.0.0-20200828125504-e418fc54dd5e/go.mod h1:XJEZ3/EQuI3BXTp/6DUzFr850vlxq11I6satRtz0YQ4=
github.com/cs3org/go-cs3apis v0.0.0-20210209082852-35ace33082f5 h1:wy1oeyy6v9/65G97AkE5o4jC9J+sngPV9AZL5TbNsaY=
github.com/cs3org/go-cs3apis v0.0.0-20210209082852-35ace33082f5/go.mod h1:UXha4TguuB52H14EMoSsCqDj7k8a/t7g4gVP+bgY5LY=
github.com/cs3org/reva v1.6.0 h1:xIhO7UtXQZbjYNeekaeQtZRo+HjZWWukCotb1tO4qMA=
github.com/cs3org/reva v1.6.0/go.mod h1:3IWlJ4RcYYu0NEnlvP9QG66Inx7F0BtVLJWXit9Q5aw=
github.com/cs3org/reva v1.6.1-0.20210223065028-53f39499762e h1:fylXfGSnDzo+X+sgxNyWoU1NjAmTJBrj2ucgNKBmb6s=
github.com/cs3org/reva v1.6.1-0.20210223065028-53f39499762e/go.mod h1:DGqsIK/psLwnWz58z8t4Gmrhx9P5iccZZkzi8CBO1c0=
github.com/cucumber/godog v0.8.1/go.mod h1:vSh3r/lM+psC1BPXvdkSEuNjmXfpVqrMGYAElF6hxnA=
@@ -1199,7 +1203,8 @@ github.com/ogier/pflag v0.0.1/go.mod h1:zkFki7tvTa0tafRvTBIZTvzYyAu6kQhPZFnshFFP
github.com/oklog/run v1.1.0 h1:GEenZ1cK0+q0+wsJew9qUg/DyD8k3JzYsZAi5gYi2mA=
github.com/oklog/run v1.1.0/go.mod h1:sVPdnTZT1zYwAJeCMu2Th4T21pA3FPOQRfWjQlk7DVU=
github.com/oklog/ulid v1.3.1/go.mod h1:CirwcVhetQ6Lv90oh/F+FBtV6XMibvdAFo93nm5qn4U=
github.com/oleiade/reflections v1.0.1 h1:D1XO3LVEYroYskEsoSiGItp9RUxG6jWnCVvrqH0HHQM=
github.com/oleiade/reflections v1.0.0 h1:0ir4pc6v8/PJ0yw5AEtMddfXpWBXg9cnG7SgSoJuCgY=
github.com/oleiade/reflections v1.0.0/go.mod h1:RbATFBbKYkVdqmSFtx13Bb/tVhR0lgOBXunWTZKeL4w=
github.com/oleiade/reflections v1.0.1/go.mod h1:rdFxbxq4QXVZWj0F+e9jqjDkc7dbp97vkRixKo2JR60=
github.com/olekukonko/tablewriter v0.0.1/go.mod h1:vsDQFd/mU46D+Z4whnwzcISnGGzXWMclvtLoiIKAKIo=
github.com/olekukonko/tablewriter v0.0.4 h1:vHD/YYe1Wolo78koG299f7V/VAS08c6IpCLn+Ejf/w8=
@@ -1477,6 +1482,8 @@ github.com/smartystreets/goconvey v1.6.4 h1:fv0U8FUIMPNf1L9lnHLvLhgicrIVChEkdzIK
github.com/smartystreets/goconvey v1.6.4/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA=
github.com/soheilhy/cmux v0.1.4 h1:0HKaf1o97UwFjHH9o5XsHUOF+tqmdA7KEzXLpiyaw0E=
github.com/soheilhy/cmux v0.1.4/go.mod h1:IM3LyeVVIOuxMH7sFAkER9+bJ4dT7Ms6E4xg4kGIyLM=
github.com/sony/gobreaker v0.4.1 h1:oMnRNZXX5j85zso6xCPRNPtmAycat+WcoKbklScLDgQ=
github.com/sony/gobreaker v0.4.1/go.mod h1:ZKptC7FHNvhBz7dN2LGjPVBz2sZJmc0/PkyDJOjmxWY=
github.com/sourcegraph/annotate v0.0.0-20160123013949-f4cad6c6324d/go.mod h1:UdhH50NIW0fCiwBSr0co2m7BnFLdv4fQTgdqdJTHFeE=
github.com/sourcegraph/syntaxhighlight v0.0.0-20170531221838-bd320f5d308e/go.mod h1:HuIsMU8RRBOtsCgI77wP899iHVBQpCmg4ErYMZB+2IA=
github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72 h1:qLC7fQah7D6K1B0ujays3HV9gkFtllcxhzImRR7ArPQ=
@@ -1499,8 +1506,6 @@ github.com/spf13/cobra v0.0.6/go.mod h1:/6GTrnGXV9HjY+aR4k0oJ5tcvakLuG6EuKReYlHN
github.com/spf13/cobra v0.0.7/go.mod h1:/6GTrnGXV9HjY+aR4k0oJ5tcvakLuG6EuKReYlHNrgE=
github.com/spf13/cobra v1.0.0 h1:6m/oheQuQ13N9ks4hubMG6BnvwOeaJrqSPLahSnczz8=
github.com/spf13/cobra v1.0.0/go.mod h1:/6GTrnGXV9HjY+aR4k0oJ5tcvakLuG6EuKReYlHNrgE=
github.com/spf13/cobra v1.1.3 h1:xghbfqPkxzxP3C/f3n5DdpAbdKLj4ZE4BWQI362l53M=
github.com/spf13/cobra v1.1.3/go.mod h1:pGADOWyqRD/YMrPZigI/zbliZ2wVD/23d+is3pSWzOo=
github.com/spf13/jwalterweatherman v1.0.0/go.mod h1:cQK4TGJAtQXfYWX+Ddv3mKDzgVb68N+wFjFa4jdeBTo=
github.com/spf13/jwalterweatherman v1.1.0 h1:ue6voC5bR5F8YxI5S67j9i582FU4Qvo2bmqnqMYADFk=
github.com/spf13/jwalterweatherman v1.1.0/go.mod h1:aNWZUN0dPAAO/Ljvb5BEdw96iTZ0EXowPYD95IqWIGo=
+3 -9
View File
@@ -37,6 +37,7 @@ var (
"proxy",
"settings",
"store",
"storage-metadata",
"storage-frontend",
"storage-gateway",
"storage-userprovider",
@@ -45,21 +46,18 @@ var (
"storage-auth-bearer",
"storage-home",
"storage-users",
"storage-metadata",
"storage-public-link",
"thumbnails",
"web",
"webdav",
"accounts",
//"graph",
//"graph-explorer",
}
// There seem to be a race condition when reva-sharing needs to read the sharing.json file and the parent folder is not present.
dependants = []string{
"accounts",
"storage-sharing",
}
// Maximum number of retries until getting a connection to the rpc runtime service.
maxRetries = 10
)
@@ -112,7 +110,7 @@ func (r *Runtime) Launch() {
client, err = rpc.DialHTTP("tcp", "localhost:10666")
if err != nil {
try++
fmt.Println("runtime not available, retrying in 1 second...")
fmt.Println("runtime not available, retrying...")
time.Sleep(1 * time.Second)
} else {
goto OUT
@@ -129,10 +127,6 @@ OUT:
}
if len(dependants) > 0 {
// TODO(refs) this should disappear and tackled at the runtime (pman) level.
// see https://github.com/cs3org/reva/issues/795 for race condition.
// dependants might not be needed on a ocis_simple build, therefore
// it should not be started under these circumstances.
time.Sleep(2 * time.Second)
for _, v := range dependants {
RunService(client, v)
+23 -65
View File
@@ -1005,7 +1005,6 @@ func TestListRolesAfterSavingBundle(t *testing.T) {
name: bundle.Name,
})
}
assert.Equal(t, len(tt.expectedBundles), len(rolesRes.Bundles))
})
}
}
@@ -1267,13 +1266,19 @@ func TestListFilteredBundle(t *testing.T) {
listRes, err := bundleService.ListBundles(ctx, &proto.ListBundlesRequest{})
assert.NoError(t, err)
for _, bundle := range listRes.Bundles {
assert.Contains(t, tt.expectedBundles, expectedBundle{
displayName: bundle.DisplayName,
name: bundle.Name,
// we don't want to deep-assert the values returned only add checks on name and displayName
// this will suffice.
listResAsExpectedBundle := make([]expectedBundle, 0)
for i := range listRes.Bundles {
listResAsExpectedBundle = append(listResAsExpectedBundle, expectedBundle{
displayName: listRes.Bundles[i].DisplayName,
name: listRes.Bundles[i].Name,
})
}
assert.Equal(t, len(tt.expectedBundles), len(listRes.Bundles))
for _, bundle := range tt.expectedBundles {
assert.Contains(t, listResAsExpectedBundle, bundle)
}
})
}
}
@@ -1568,13 +1573,19 @@ func TestListGetBundleSettingMixedPermission(t *testing.T) {
listRes, err := bundleService.ListBundles(ctx, &proto.ListBundlesRequest{})
assert.NoError(t, err)
for _, setting := range listRes.Bundles[0].Settings {
assert.Contains(t, tt.expectedSettings, expectedSetting{
displayName: setting.DisplayName,
name: setting.Name,
})
listedSettings := make([]expectedSetting, 0)
for i := range listRes.Bundles {
for _, setting := range listRes.Bundles[i].Settings {
listedSettings = append(listedSettings, expectedSetting{
displayName: setting.DisplayName,
name: setting.Name,
})
}
}
for i := range tt.expectedSettings {
assert.Contains(t, listedSettings, tt.expectedSettings[i])
}
assert.Equal(t, len(tt.expectedSettings), len(listRes.Bundles[0].Settings))
getRes, err := bundleService.GetBundle(ctx, &proto.GetBundleRequest{BundleId: bundle.Id})
assert.NoError(t, err)
@@ -1585,59 +1596,6 @@ func TestListGetBundleSettingMixedPermission(t *testing.T) {
name: setting.Name,
})
}
assert.Equal(t, len(tt.expectedSettings), len(getRes.Bundle.Settings))
})
}
}
func TestListFilteredBundle_SetPermissionsOnSettingAndBundle(t *testing.T) {
tests := []struct {
name string
settingPermission proto.Permission_Operation
bundlePermission proto.Permission_Operation
expectedAmountOfSettings int
}{
{
"setting has read permission bundle not",
proto.Permission_OPERATION_READ,
proto.Permission_OPERATION_UNKNOWN,
1,
},
{
"bundle has read permission setting not",
proto.Permission_OPERATION_UNKNOWN,
proto.Permission_OPERATION_READ,
5,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
teardown := setup()
defer teardown()
ctx := metadata.Set(context.Background(), middleware.AccountID, testAccountID)
ctx = metadata.Set(ctx, middleware.RoleIDs, getRoleIDAsJSON(svc.BundleUUIDRoleAdmin))
_, err := bundleService.SaveBundle(ctx, &proto.SaveBundleRequest{
Bundle: &bundleStub,
})
assert.NoError(t, err)
setPermissionOnBundleOrSetting(
ctx, t, bundleStub.Id, proto.Resource_TYPE_BUNDLE, tt.bundlePermission, svc.BundleUUIDRoleAdmin,
)
setPermissionOnBundleOrSetting(
ctx, t, bundleStub.Settings[0].Id, proto.Resource_TYPE_SETTING,
tt.settingPermission, svc.BundleUUIDRoleAdmin,
)
listRes, err := bundleService.ListBundles(ctx, &proto.ListBundlesRequest{})
assert.NoError(t, err)
assert.Equal(t, 1, len(listRes.Bundles))
assert.Equal(t, tt.expectedAmountOfSettings, len(listRes.Bundles[0].Settings))
assert.Equal(t, bundleStub.Id, listRes.Bundles[0].Id)
assert.Equal(t, bundleStub.Settings[0].Id, listRes.Bundles[0].Settings[0].Id)
})
}
}
+6
View File
@@ -65,6 +65,12 @@ func (g Service) RegisterDefaultRoles() {
Msg("failed to register permission")
}
}
for _, req := range defaultRoleAssignments() {
if _, err := g.manager.WriteRoleAssignment(req.AccountUuid, req.RoleId); err != nil {
g.logger.Error().Err(err).Msg("failed to register role assignment")
}
}
}
// TODO: check permissions on every request
+248 -1
View File
@@ -1,6 +1,8 @@
package svc
import settings "github.com/owncloud/ocis/settings/pkg/proto/v0"
import (
settings "github.com/owncloud/ocis/settings/pkg/proto/v0"
)
const (
// BundleUUIDRoleAdmin represents the admin role
@@ -21,6 +23,21 @@ const (
SettingsManagementPermissionID string = "79e13b30-3e22-11eb-bc51-0b9f0bad9a58"
// SettingsManagementPermissionName is the hardcoded setting name for the settings management permission
SettingsManagementPermissionName string = "settings-management"
settingUUIDProfileLanguage = "aa8cfbe5-95d4-4f7e-a032-c3c01f5f062f"
// AccountManagementPermissionID is the hardcoded setting UUID for the account management permission
AccountManagementPermissionID string = "8e587774-d929-4215-910b-a317b1e80f73"
// AccountManagementPermissionName is the hardcoded setting name for the account management permission
AccountManagementPermissionName string = "account-management"
// GroupManagementPermissionID is the hardcoded setting UUID for the group management permission
GroupManagementPermissionID string = "522adfbe-5908-45b4-b135-41979de73245"
// GroupManagementPermissionName is the hardcoded setting name for the group management permission
GroupManagementPermissionName string = "group-management"
// SelfManagementPermissionID is the hardcoded setting UUID for the self management permission
SelfManagementPermissionID string = "e03070e9-4362-4cc6-a872-1c7cb2eb2b8e"
// SelfManagementPermissionName is the hardcoded setting name for the self management permission
SelfManagementPermissionName string = "self-management"
)
// generateBundlesDefaultRoles bootstraps the default roles.
@@ -29,6 +46,7 @@ func generateBundlesDefaultRoles() []*settings.Bundle {
generateBundleAdminRole(),
generateBundleUserRole(),
generateBundleGuestRole(),
generateBundleProfileRequest(),
}
}
@@ -74,6 +92,94 @@ func generateBundleGuestRole() *settings.Bundle {
}
}
var languageSetting = settings.Setting_SingleChoiceValue{
SingleChoiceValue: &settings.SingleChoiceList{
Options: []*settings.ListOption{
{
Value: &settings.ListOptionValue{
Option: &settings.ListOptionValue_StringValue{
StringValue: "cs",
},
},
DisplayValue: "Czech",
},
{
Value: &settings.ListOptionValue{
Option: &settings.ListOptionValue_StringValue{
StringValue: "de",
},
},
DisplayValue: "Deutsch",
},
{
Value: &settings.ListOptionValue{
Option: &settings.ListOptionValue_StringValue{
StringValue: "en",
},
},
DisplayValue: "English",
},
{
Value: &settings.ListOptionValue{
Option: &settings.ListOptionValue_StringValue{
StringValue: "es",
},
},
DisplayValue: "Español",
},
{
Value: &settings.ListOptionValue{
Option: &settings.ListOptionValue_StringValue{
StringValue: "fr",
},
},
DisplayValue: "Français",
},
{
Value: &settings.ListOptionValue{
Option: &settings.ListOptionValue_StringValue{
StringValue: "gl",
},
},
DisplayValue: "Galego",
},
{
Value: &settings.ListOptionValue{
Option: &settings.ListOptionValue_StringValue{
StringValue: "it",
},
},
DisplayValue: "Italiano",
},
},
},
}
func generateBundleProfileRequest() *settings.Bundle {
return &settings.Bundle{
Id: "2a506de7-99bd-4f0d-994e-c38e72c28fd9",
Name: "profile",
Extension: "ocis-accounts",
Type: settings.Bundle_TYPE_DEFAULT,
Resource: &settings.Resource{
Type: settings.Resource_TYPE_SYSTEM,
},
DisplayName: "Profile",
Settings: []*settings.Setting{
{
Id: settingUUIDProfileLanguage,
Name: "language",
DisplayName: "Language",
Description: "User language",
Resource: &settings.Resource{
Type: settings.Resource_TYPE_USER,
},
Value: &languageSetting,
},
},
}
}
func generatePermissionRequests() []*settings.AddSettingToBundleRequest {
return []*settings.AddSettingToBundleRequest{
{
@@ -114,5 +220,146 @@ func generatePermissionRequests() []*settings.AddSettingToBundleRequest {
},
},
},
{
BundleId: BundleUUIDRoleAdmin,
Setting: &settings.Setting{
Id: "7d81f103-0488-4853-bce5-98dcce36d649",
Name: "language-readwrite",
DisplayName: "Permission to read and set the language (anyone)",
Resource: &settings.Resource{
Type: settings.Resource_TYPE_SETTING,
Id: settingUUIDProfileLanguage,
},
Value: &settings.Setting_PermissionValue{
PermissionValue: &settings.Permission{
Operation: settings.Permission_OPERATION_READWRITE,
Constraint: settings.Permission_CONSTRAINT_ALL,
},
},
},
},
{
BundleId: BundleUUIDRoleUser,
Setting: &settings.Setting{
Id: "640e00d2-4df8-41bd-b1c2-9f30a01e0e99",
Name: "language-readwrite",
DisplayName: "Permission to read and set the language (self)",
Resource: &settings.Resource{
Type: settings.Resource_TYPE_SETTING,
Id: settingUUIDProfileLanguage,
},
Value: &settings.Setting_PermissionValue{
PermissionValue: &settings.Permission{
Operation: settings.Permission_OPERATION_READWRITE,
Constraint: settings.Permission_CONSTRAINT_OWN,
},
},
},
},
{
BundleId: BundleUUIDRoleGuest,
Setting: &settings.Setting{
Id: "ca878636-8b1a-4fae-8282-8617a4c13597",
Name: "language-readwrite",
DisplayName: "Permission to read and set the language (self)",
Resource: &settings.Resource{
Type: settings.Resource_TYPE_SETTING,
Id: settingUUIDProfileLanguage,
},
Value: &settings.Setting_PermissionValue{
PermissionValue: &settings.Permission{
Operation: settings.Permission_OPERATION_READWRITE,
Constraint: settings.Permission_CONSTRAINT_OWN,
},
},
},
},
{
BundleId: BundleUUIDRoleAdmin,
Setting: &settings.Setting{
Id: AccountManagementPermissionID,
Name: AccountManagementPermissionName,
DisplayName: "Account Management",
Description: "This permission gives full access to everything that is related to account management.",
Resource: &settings.Resource{
Type: settings.Resource_TYPE_USER,
Id: "all",
},
Value: &settings.Setting_PermissionValue{
PermissionValue: &settings.Permission{
Operation: settings.Permission_OPERATION_READWRITE,
Constraint: settings.Permission_CONSTRAINT_ALL,
},
},
},
},
{
BundleId: BundleUUIDRoleAdmin,
Setting: &settings.Setting{
Id: GroupManagementPermissionID,
Name: GroupManagementPermissionName,
DisplayName: "Group Management",
Description: "This permission gives full access to everything that is related to group management.",
Resource: &settings.Resource{
Type: settings.Resource_TYPE_GROUP,
Id: "all",
},
Value: &settings.Setting_PermissionValue{
PermissionValue: &settings.Permission{
Operation: settings.Permission_OPERATION_READWRITE,
Constraint: settings.Permission_CONSTRAINT_ALL,
},
},
},
},
{
BundleId: BundleUUIDRoleUser,
Setting: &settings.Setting{
Id: SelfManagementPermissionID,
Name: SelfManagementPermissionName,
DisplayName: "Self Management",
Description: "This permission gives access to self management.",
Resource: &settings.Resource{
Type: settings.Resource_TYPE_USER,
Id: "me",
},
Value: &settings.Setting_PermissionValue{
PermissionValue: &settings.Permission{
Operation: settings.Permission_OPERATION_READWRITE,
Constraint: settings.Permission_CONSTRAINT_OWN,
},
},
},
},
}
}
func defaultRoleAssignments() []*settings.UserRoleAssignment {
return []*settings.UserRoleAssignment{
// default admin users
{
AccountUuid: "058bff95-6708-4fe5-91e4-9ea3d377588b",
RoleId: BundleUUIDRoleAdmin,
}, {
AccountUuid: "ddc2004c-0977-11eb-9d3f-a793888cd0f8",
RoleId: BundleUUIDRoleAdmin,
}, {
AccountUuid: "820ba2a1-3f54-4538-80a4-2d73007e30bf",
RoleId: BundleUUIDRoleAdmin,
}, {
AccountUuid: "bc596f3c-c955-4328-80a0-60d018b4ad57",
RoleId: BundleUUIDRoleAdmin,
},
// default users with role "user"
{
AccountUuid: "4c510ada-c86b-4815-8820-42cdf82c3d51",
RoleId: BundleUUIDRoleUser,
}, {
AccountUuid: "f7fbf8c8-139b-4376-b307-cf0a8c2d0d9c",
RoleId: BundleUUIDRoleUser,
}, {
AccountUuid: "932b4540-8d16-481e-8ef4-588e4b6b151c",
RoleId: BundleUUIDRoleUser,
},
}
}
+2
View File
@@ -4,6 +4,8 @@ go 1.15
require (
github.com/Masterminds/sprig/v3 v3.2.2 // indirect
github.com/asim/go-micro/plugins/registry/kubernetes/v3 v3.0.0-20210217182006-0f0ace1a44a9 // indirect
github.com/asim/go-micro/plugins/registry/nats/v3 v3.0.0-20210217182006-0f0ace1a44a9 // indirect
github.com/asim/go-micro/v3 v3.5.1-0.20210217182006-0f0ace1a44a9
github.com/cs3org/reva v1.6.1-0.20210223065028-53f39499762e
github.com/gofrs/uuid v3.3.0+incompatible
+11 -1
View File
@@ -7,8 +7,10 @@ import (
"path"
"time"
"github.com/cs3org/reva/cmd/revad/runtime"
"github.com/gofrs/uuid"
"github.com/owncloud/ocis/storage/pkg/service/external"
"github.com/cs3org/reva/cmd/revad/runtime"
"github.com/micro/cli/v2"
"github.com/oklog/run"
"github.com/owncloud/ocis/storage/pkg/config"
@@ -201,6 +203,14 @@ func StorageMetadata(cfg *config.Config) *cli.Command {
})
}
external.RegisterGRPCEndpoint(
ctx,
"com.owncloud.storage.metadata",
uuid.Must(uuid.NewV4()).String(),
cfg.Reva.StorageMetadata.GRPCAddr,
logger,
)
return gr.Run()
},
}