Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix settings and idm admin user id configuration #3799

Merged
merged 2 commits into from
May 16, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .bingo/Variables.mk
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
BINGO_DIR := $(dir $(lastword $(MAKEFILE_LIST)))
GOPATH ?= $(shell go env GOPATH)
GOBIN ?= $(firstword $(subst :, ,${GOPATH}))/bin
GO ?= $(shell command -v go)
GO ?= $(shell which go)

# Below generated variables ensure that every time a tool under each variable is invoked, the correct version
# will be used; reinstalling only if needed.
Expand Down
9 changes: 9 additions & 0 deletions changelog/unreleased/fix-settings-idm-adminuserid.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
Bugfix: Fix the idm and settings extensions' admin user id configuration option

We've fixed the admin user id configuration of the settings and idm extensions.
The have previously only been configurable via the oCIS shared configuration and
therefore have been undocumented for the extensions. This config option is now part
of both extensions' configuration and can now also be used when the extensions are
compiled standalone.

https://github.com/owncloud/ocis/pull/3799
2 changes: 1 addition & 1 deletion extensions/idm/pkg/command/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ func bootstrap(logger log.Logger, cfg *config.Config, srvcfg server.Config) erro
{
Name: "admin",
Password: cfg.ServiceUserPasswords.OcisAdmin,
ID: cfg.Commons.AdminUserID,
ID: cfg.AdminUserID,
},
{
Name: "libregraph",
Expand Down
1 change: 1 addition & 0 deletions extensions/idm/pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ type Config struct {
CreateDemoUsers bool `yaml:"create_demo_users" env:"IDM_CREATE_DEMO_USERS;ACCOUNTS_DEMO_USERS_AND_GROUPS" desc:"Flag to enabe/disable the creation of the demo users"`

ServiceUserPasswords ServiceUserPasswords `yaml:"service_user_passwords"`
AdminUserID string `yaml:"admin_user_id" env:"OCIS_ADMIN_USER_ID;IDM_ADMIN_USER_ID"`

Context context.Context `yaml:"-"`
}
Expand Down
4 changes: 4 additions & 0 deletions extensions/idm/pkg/config/defaults/defaultconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@ func EnsureDefaults(cfg *config.Config) {
} else if cfg.Tracing == nil {
cfg.Tracing = &config.Tracing{}
}

if cfg.AdminUserID == "" && cfg.Commons != nil {
cfg.AdminUserID = cfg.Commons.AdminUserID
}
}

func Sanitize(cfg *config.Config) {
Expand Down
2 changes: 2 additions & 0 deletions extensions/settings/pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ type Config struct {
DataPath string `yaml:"data_path" env:"SETTINGS_DATA_PATH"`
Metadata Metadata `yaml:"metadata_config"`

AdminUserID string `yaml:"admin_user_id" env:"OCIS_ADMIN_USER_ID;SETTINGS_ADMIN_USER_ID"`

Asset Asset `yaml:"asset"`
TokenManager *TokenManager `yaml:"token_manager"`

Expand Down
4 changes: 4 additions & 0 deletions extensions/settings/pkg/config/defaults/defaultconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,10 @@ func EnsureDefaults(cfg *config.Config) {
if cfg.Metadata.SystemUserID == "" && cfg.Commons != nil && cfg.Commons.SystemUserID != "" {
cfg.Metadata.SystemUserID = cfg.Commons.SystemUserID
}

if cfg.AdminUserID == "" && cfg.Commons != nil {
cfg.AdminUserID = cfg.Commons.AdminUserID
}
}

func Sanitize(cfg *config.Config) {
Expand Down
2 changes: 1 addition & 1 deletion extensions/settings/pkg/service/v0/settings.go
Original file line number Diff line number Diff line change
Expand Up @@ -539,7 +539,7 @@ func (g Service) defaultRoleAssignments() []*settingsmsg.UserRoleAssignment {
AccountUuid: "058bff95-6708-4fe5-91e4-9ea3d377588b", // demo user "moss"
RoleId: BundleUUIDRoleAdmin,
}, {
AccountUuid: g.config.Commons.AdminUserID,
AccountUuid: g.config.AdminUserID,
RoleId: BundleUUIDRoleAdmin,
},
// default users with role "user"
Expand Down
2 changes: 1 addition & 1 deletion extensions/settings/pkg/store/defaults/defaults.go
Original file line number Diff line number Diff line change
Expand Up @@ -504,7 +504,7 @@ func DefaultRoleAssignments(cfg *config.Config) []*settingsmsg.UserRoleAssignmen
AccountUuid: "058bff95-6708-4fe5-91e4-9ea3d377588b", // demo user "moss"
RoleId: BundleUUIDRoleAdmin,
}, {
AccountUuid: cfg.Commons.AdminUserID,
AccountUuid: cfg.AdminUserID,
RoleId: BundleUUIDRoleAdmin,
},
// default users with role "user"
Expand Down