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

MetadataUserID -> SystemUserID #3671

Merged
merged 4 commits into from
May 4, 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
5 changes: 5 additions & 0 deletions changelog/unreleased/metadatauserid-systemuserid.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Change: rename MetadataUserID

MetadataUserID is renamed to SystemUserID including yaml tags and env vars

https://github.com/owncloud/ocis/pull/3671
4 changes: 2 additions & 2 deletions extensions/settings/pkg/config/defaults/defaultconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,8 @@ func EnsureDefaults(cfg *config.Config) {
cfg.Metadata.MachineAuthAPIKey = cfg.Commons.MachineAuthAPIKey
}

if cfg.Metadata.ServiceUserID == "" && cfg.Commons != nil && cfg.Commons.MetadataUserID != "" {
cfg.Metadata.ServiceUserID = cfg.Commons.MetadataUserID
if cfg.Metadata.ServiceUserID == "" && cfg.Commons != nil && cfg.Commons.SystemUserID != "" {
cfg.Metadata.ServiceUserID = cfg.Commons.SystemUserID
}
}

Expand Down
8 changes: 4 additions & 4 deletions extensions/sharing/pkg/config/defaults/defaultconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,16 +104,16 @@ func EnsureDefaults(cfg *config.Config) {
cfg.UserSharingDrivers.CS3.MachineAuthAPIKey = cfg.Commons.MachineAuthAPIKey
}

if cfg.UserSharingDrivers.CS3.ServiceUserID == "" && cfg.Commons != nil && cfg.Commons.MetadataUserID != "" {
cfg.UserSharingDrivers.CS3.ServiceUserID = cfg.Commons.MetadataUserID
if cfg.UserSharingDrivers.CS3.ServiceUserID == "" && cfg.Commons != nil && cfg.Commons.SystemUserID != "" {
cfg.UserSharingDrivers.CS3.ServiceUserID = cfg.Commons.SystemUserID
}

if cfg.PublicSharingDrivers.CS3.MachineAuthAPIKey == "" && cfg.Commons != nil && cfg.Commons.MachineAuthAPIKey != "" {
cfg.PublicSharingDrivers.CS3.MachineAuthAPIKey = cfg.Commons.MachineAuthAPIKey
}

if cfg.PublicSharingDrivers.CS3.ServiceUserID == "" && cfg.Commons != nil && cfg.Commons.MetadataUserID != "" {
cfg.PublicSharingDrivers.CS3.ServiceUserID = cfg.Commons.MetadataUserID
if cfg.PublicSharingDrivers.CS3.ServiceUserID == "" && cfg.Commons != nil && cfg.Commons.SystemUserID != "" {
cfg.PublicSharingDrivers.CS3.ServiceUserID = cfg.Commons.SystemUserID
}
}

Expand Down
4 changes: 2 additions & 2 deletions extensions/sharing/pkg/config/parser/parse.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,15 @@ func Validate(cfg *config.Config) error {
}

if cfg.PublicSharingDriver == "cs3" && cfg.PublicSharingDrivers.CS3.ServiceUserID == "" {
return shared.MissingMetadataUserID(cfg.Service.Name)
return shared.MissingSystemUserID(cfg.Service.Name)
}

if cfg.UserSharingDriver == "cs3" && cfg.UserSharingDrivers.CS3.MachineAuthAPIKey == "" {
return shared.MissingMachineAuthApiKeyError(cfg.Service.Name)
}

if cfg.UserSharingDriver == "cs3" && cfg.UserSharingDrivers.CS3.ServiceUserID == "" {
return shared.MissingMetadataUserID(cfg.Service.Name)
return shared.MissingSystemUserID(cfg.Service.Name)
}

return nil
Expand Down
2 changes: 1 addition & 1 deletion extensions/storage-system/pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ type Config struct {
TokenManager *TokenManager `yaml:"token_manager"`
Reva *Reva `yaml:"reva"`
MachineAuthAPIKey string `yaml:"machine_auth_api_key" env:"STORAGE_SYSTEM_MACHINE_AUTH_API_KEY"`
MetadataUserID string `yaml:"metadata_user_id"`
SystemUserID string `yaml:"system_user_id"`

SkipUserGroupsInToken bool `yaml:"skip_user_groups_in_token" env:"STORAGE_SYSTEM_SKIP_USER_GROUPS_IN_TOKEN"`

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,8 @@ func EnsureDefaults(cfg *config.Config) {
cfg.MachineAuthAPIKey = cfg.Commons.MachineAuthAPIKey
}

if cfg.MetadataUserID == "" && cfg.Commons != nil && cfg.Commons.MetadataUserID != "" {
cfg.MetadataUserID = cfg.Commons.MetadataUserID
if cfg.SystemUserID == "" && cfg.Commons != nil && cfg.Commons.SystemUserID != "" {
cfg.SystemUserID = cfg.Commons.SystemUserID
}

}
Expand Down
4 changes: 2 additions & 2 deletions extensions/storage-system/pkg/config/parser/parse.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ func Validate(cfg *config.Config) error {
return shared.MissingMachineAuthApiKeyError(cfg.Service.Name)
}

if cfg.MetadataUserID == "" {
return shared.MissingMetadataUserID(cfg.Service.Name)
if cfg.SystemUserID == "" {
return shared.MissingSystemUserID(cfg.Service.Name)
}
return nil
}
2 changes: 1 addition & 1 deletion extensions/storage-system/pkg/revaconfig/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ func StorageMetadataFromStruct(cfg *config.Config) map[string]interface{} {
"users": map[string]interface{}{
"serviceuser": map[string]interface{}{
"id": map[string]interface{}{
"opaqueId": cfg.MetadataUserID,
"opaqueId": cfg.SystemUserID,
"idp": "internal",
"type": userpb.UserType_USER_TYPE_PRIMARY,
},
Expand Down
2 changes: 1 addition & 1 deletion ocis-pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ type Config struct {
TokenManager *shared.TokenManager `yaml:"token_manager"`
MachineAuthAPIKey string `yaml:"machine_auth_api_key" env:"OCIS_MACHINE_AUTH_API_KEY"`
TransferSecret string `yaml:"transfer_secret" env:"STORAGE_TRANSFER_SECRET"`
MetadataUserID string `yaml:"metadata_user_id" env:"METADATA_USER_ID"`
SystemUserID string `yaml:"system_user_id" env:"OCIS_SYSTEM_USER_ID"`
Runtime Runtime `yaml:"runtime"`

Accounts *accounts.Config `yaml:"accounts"`
Expand Down
8 changes: 4 additions & 4 deletions ocis-pkg/config/parser/parse.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,8 @@ func EnsureCommons(cfg *config.Config) {
}

// copy metadata user id to the commons part if set
if cfg.MetadataUserID != "" {
cfg.Commons.MetadataUserID = cfg.MetadataUserID
if cfg.SystemUserID != "" {
cfg.Commons.SystemUserID = cfg.SystemUserID
}
}

Expand All @@ -113,8 +113,8 @@ func Validate(cfg *config.Config) error {
return shared.MissingMachineAuthApiKeyError("ocis")
}

if cfg.MetadataUserID == "" {
return shared.MissingMetadataUserID("ocis")
if cfg.SystemUserID == "" {
return shared.MissingSystemUserID("ocis")
}

return nil
Expand Down
2 changes: 1 addition & 1 deletion ocis-pkg/shared/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ func MissingServiceUserPassword(service, serviceUser string) error {
serviceUser, service, defaults.BaseConfigPath())
}

func MissingMetadataUserID(service string) error {
func MissingSystemUserID(service string) error {
return fmt.Errorf("The metadata user ID has not been configured for %s. "+
"Make sure your %s config contains the proper values "+
"(e.g. by running ocis init or setting it manually in "+
Expand Down
2 changes: 1 addition & 1 deletion ocis-pkg/shared/shared_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,5 +44,5 @@ type Commons struct {
Reva *Reva `yaml:"reva"`
MachineAuthAPIKey string `yaml:"machine_auth_api_key" env:"OCIS_MACHINE_AUTH_API_KEY"`
TransferSecret string `yaml:"transfer_secret,omitempty" env:"REVA_TRANSFER_SECRET"`
MetadataUserID string `yaml:"metadata_user_id" env:"METADATA_USER_ID"`
SystemUserID string `yaml:"system_user_id" env:"OCIS_SYSTEM_USER_ID"`
}
6 changes: 3 additions & 3 deletions ocis/pkg/init/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ type OcisConfig struct {
TokenManager TokenManager `yaml:"token_manager"`
MachineAuthApiKey string `yaml:"machine_auth_api_key"`
TransferSecret string `yaml:"transfer_secret"`
MetadataUserID string `yaml:"metadata_user_id"`
SystemUserID string `yaml:"system_user_id"`
Graph GraphExtension
Idp LdapBasedExtension
Idm IdmExtension
Expand Down Expand Up @@ -161,7 +161,7 @@ func CreateConfig(insecure, forceOverwrite bool, configPath, adminPassword strin
return err
}

metadataUserID := uuid.Must(uuid.NewV4()).String()
systemUserID := uuid.Must(uuid.NewV4()).String()

idmServicePassword, err := generators.GenerateRandomPassword(passwordLength)
if err != nil {
Expand Down Expand Up @@ -202,7 +202,7 @@ func CreateConfig(insecure, forceOverwrite bool, configPath, adminPassword strin
},
MachineAuthApiKey: machineAuthApiKey,
TransferSecret: revaTransferSecret,
MetadataUserID: metadataUserID,
SystemUserID: systemUserID,
Idm: IdmExtension{
ServiceUserPasswords: ServiceUserPasswordsSettings{
AdminPassword: ocisAdminServicePassword,
Expand Down