From a1de086cd85d87bcaeaee6ac85d282e6c546a405 Mon Sep 17 00:00:00 2001 From: Samir Patel <48686912+54mir@users.noreply.github.com> Date: Wed, 15 Dec 2021 14:53:04 -0600 Subject: [PATCH] change scopes from string to slicee --- ctl/server.go | 2 +- install/featurebase.conf | 2 +- server/config.go | 6 ++++-- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/ctl/server.go b/ctl/server.go index 0c65c4c5c..627f3e916 100644 --- a/ctl/server.go +++ b/ctl/server.go @@ -116,7 +116,7 @@ func BuildServerFlags(cmd *cobra.Command, srv *server.Command) { flags.StringVar(&srv.Config.Auth.AuthorizeURL, "auth.authorize-url", srv.Config.Auth.AuthorizeURL, "Identity Provider's Authorize URL.") flags.StringVar(&srv.Config.Auth.TokenURL, "auth.token-url", srv.Config.Auth.TokenURL, "Identity Provider's Token URL.") flags.StringVar(&srv.Config.Auth.GroupEndpointURL, "auth.group-endpoint-url", srv.Config.Auth.GroupEndpointURL, "Identity Provider's Group endpoint URL.") - flags.StringVar(&srv.Config.Auth.ScopeURL, "auth.scope-url", srv.Config.Auth.ScopeURL, "Identity Provider's Scope URL.") + flags.StringSliceVar(&srv.Config.Auth.Scopes, "auth.scopes", srv.Config.Auth.Scopes, "Comma separated list of scopes obtained from IdP") flags.StringVar(&srv.Config.Auth.HashKey, "auth.hash-key", srv.Config.Auth.HashKey, "First Secret for Auth.") flags.StringVar(&srv.Config.Auth.BlockKey, "auth.block-key", srv.Config.Auth.BlockKey, "Second Secret for Auth.") diff --git a/install/featurebase.conf b/install/featurebase.conf index 62671e018..a071f95f9 100644 --- a/install/featurebase.conf +++ b/install/featurebase.conf @@ -381,6 +381,6 @@ log-path = "/var/log/molecula/featurebase.log" # authorize-url = "https://login.microsoftonline.com/4a137d66-d161-4ae4-b1e6-07e9920874b8/oauth2/v2.0/authorize" # token-url = "https://login.microsoftonline.com/4a137d66-d161-4ae4-b1e6-07e9920874b8/oauth2/v2.0/token" # group-endpoint-url = "https://graph.microsoft.com/v1.0/me/transitiveMemberOf/microsoft.graph.group?$count=true" -# scope-url = ["https://graph.microsoft.com/.default", "offline_access"] +# scopes = ["https://graph.microsoft.com/.default", "offline_access"] # hash-key = "" # block-key = "" \ No newline at end of file diff --git a/server/config.go b/server/config.go index 677f67261..84d22a26b 100644 --- a/server/config.go +++ b/server/config.go @@ -249,7 +249,7 @@ type Config struct { GroupEndpointURL string `toml:"group-endpoint-url"` // Scope URL - ScopeURL string `toml:"scope-url"` + Scopes []string `toml:"scopes"` // Hash Key HashKey string `toml:"hash-key"` @@ -631,7 +631,6 @@ func (c *Config) ValidateAuth() ([]error, error) { "AuthorizeURL": c.Auth.AuthorizeURL, "TokenURL": c.Auth.TokenURL, "GroupEndpointURL": c.Auth.GroupEndpointURL, - "ScopeURL": c.Auth.ScopeURL, "HashKey": c.Auth.HashKey, "BlockKey": c.Auth.BlockKey, } @@ -651,6 +650,9 @@ func (c *Config) ValidateAuth() ([]error, error) { } } } + if len(c.Auth.Scopes) == 0 { + errors = append(errors, fmt.Errorf("must provide scope for authentication with IdP")) + } if len(errors) > 0 { return errors, fmt.Errorf("there were errors validating config") }