change scopes from string to slicee

This commit is contained in:
Samir Patel 2021-12-15 14:53:04 -06:00
parent 1bd935bb59
commit a1de086cd8
3 changed files with 6 additions and 4 deletions

View file

@ -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.")

View file

@ -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 = ""

View file

@ -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")
}