From f643de22c4289b69b22871091d4e155f5ff72a25 Mon Sep 17 00:00:00 2001 From: Willy Kloucek Date: Mon, 2 May 2022 16:35:48 +0200 Subject: [PATCH] machine auth config docs --- extensions/auth-machine/pkg/command/command.go | 3 +-- extensions/auth-machine/pkg/config/config.go | 13 ++----------- .../pkg/config/defaults/defaultconfig.go | 5 ++--- extensions/auth-machine/pkg/config/parser/parse.go | 2 +- 4 files changed, 6 insertions(+), 17 deletions(-) diff --git a/extensions/auth-machine/pkg/command/command.go b/extensions/auth-machine/pkg/command/command.go index 674c7b220f..1e79ac6689 100644 --- a/extensions/auth-machine/pkg/command/command.go +++ b/extensions/auth-machine/pkg/command/command.go @@ -106,13 +106,12 @@ func authMachineConfigFromStruct(c *cli.Context, cfg *config.Config) map[string] "grpc": map[string]interface{}{ "network": cfg.GRPC.Protocol, "address": cfg.GRPC.Addr, - // TODO build services dynamically "services": map[string]interface{}{ "authprovider": map[string]interface{}{ "auth_manager": "machine", "auth_managers": map[string]interface{}{ "machine": map[string]interface{}{ - "api_key": cfg.AuthProviders.Machine.APIKey, + "api_key": cfg.MachineAuthAPIKey, "gateway_addr": cfg.Reva.Address, }, }, diff --git a/extensions/auth-machine/pkg/config/config.go b/extensions/auth-machine/pkg/config/config.go index 19ff424c9b..4d145eed03 100644 --- a/extensions/auth-machine/pkg/config/config.go +++ b/extensions/auth-machine/pkg/config/config.go @@ -15,9 +15,8 @@ type Config struct { TokenManager *TokenManager `yaml:"token_manager"` Reva *Reva `yaml:"reva"` - SkipUserGroupsInToken bool `yaml:"skip_user_groups_in_token"` - AuthProvider string `yaml:"auth_provider" env:"AUTH_MACHINE_AUTH_PROVIDER" desc:"The auth provider which should be used by the service"` - AuthProviders AuthProviders `yaml:"auth_providers"` + SkipUserGroupsInToken bool `yaml:"skip_user_groups_in_token"` + MachineAuthAPIKey string `yaml:"machine_auth_api_key" env:"OCIS_MACHINE_AUTH_API_KEY;AUTH_MACHINE_API_KEY"` } type Tracing struct { Enabled bool `yaml:"enabled" env:"OCIS_TRACING_ENABLED;AUTH_MACHINE_TRACING_ENABLED" desc:"Activates tracing."` @@ -48,11 +47,3 @@ type GRPCConfig struct { Addr string `yaml:"addr" env:"AUTH_MACHINE_GRPC_ADDR" desc:"The address of the grpc service."` Protocol string `yaml:"protocol" env:"AUTH_MACHINE_GRPC_PROTOCOL" desc:"The transport protocol of the grpc service."` } - -type AuthProviders struct { - Machine MachineProvider `yaml:"machine"` -} - -type MachineProvider struct { - APIKey string `yaml:"api_key" env:"OCIS_MACHINE_AUTH_API_KEY;AUTH_MACHINE_PROVIDER_API_KEY" desc:"The api key for the machine auth provider."` -} diff --git a/extensions/auth-machine/pkg/config/defaults/defaultconfig.go b/extensions/auth-machine/pkg/config/defaults/defaultconfig.go index 47b0f1a16a..7a102f4d26 100644 --- a/extensions/auth-machine/pkg/config/defaults/defaultconfig.go +++ b/extensions/auth-machine/pkg/config/defaults/defaultconfig.go @@ -29,7 +29,6 @@ func DefaultConfig() *config.Config { Reva: &config.Reva{ Address: "127.0.0.1:9142", }, - AuthProvider: "ldap", } } @@ -73,8 +72,8 @@ func EnsureDefaults(cfg *config.Config) { cfg.TokenManager = &config.TokenManager{} } - if cfg.AuthProviders.Machine.APIKey == "" && cfg.Commons != nil && cfg.Commons.MachineAuthAPIKey != "" { - cfg.AuthProviders.Machine.APIKey = cfg.Commons.MachineAuthAPIKey + if cfg.MachineAuthAPIKey == "" && cfg.Commons != nil && cfg.Commons.MachineAuthAPIKey != "" { + cfg.MachineAuthAPIKey = cfg.Commons.MachineAuthAPIKey } } diff --git a/extensions/auth-machine/pkg/config/parser/parse.go b/extensions/auth-machine/pkg/config/parser/parse.go index 2eb535806b..00a46b8469 100644 --- a/extensions/auth-machine/pkg/config/parser/parse.go +++ b/extensions/auth-machine/pkg/config/parser/parse.go @@ -38,7 +38,7 @@ func Validate(cfg *config.Config) error { return shared.MissingJWTTokenError(cfg.Service.Name) } - if cfg.AuthProviders.Machine.APIKey == "" { + if cfg.MachineAuthAPIKey == "" { return shared.MissingMachineAuthApiKeyError(cfg.Service.Name) } return nil