From c7ec788ce16ef120c8016fcbb7f03bd961dd5c1b Mon Sep 17 00:00:00 2001 From: Stavros Date: Sat, 25 Jan 2025 10:25:20 +0200 Subject: [PATCH] fix: split generic scopes string to array --- cmd/root.go | 4 ++-- internal/providers/providers.go | 2 +- internal/types/types.go | 2 +- internal/utils/utils.go | 6 +++--- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/cmd/root.go b/cmd/root.go index a16a089..0908675 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -57,7 +57,7 @@ var rootCmd = &cobra.Command{ HandleError(parseErr, "Failed to parse users") // Create whitelist - whitelist := utils.ParseWhitelist(config.Whitelist) + whitelist := utils.ParseCommaString(config.Whitelist) // Create OAuth config oauthConfig := types.OAuthConfig{ @@ -67,7 +67,7 @@ var rootCmd = &cobra.Command{ GoogleClientSecret: config.GoogleClientSecret, GenericClientId: config.GenericClientId, GenericClientSecret: config.GenericClientSecret, - GenericScopes: config.GenericScopes, + GenericScopes: utils.ParseCommaString(config.GenericScopes), GenericAuthURL: config.GenericAuthURL, GenericTokenURL: config.GenericTokenURL, GenericUserURL: config.GenericUserURL, diff --git a/internal/providers/providers.go b/internal/providers/providers.go index f3f9754..0b8db1d 100644 --- a/internal/providers/providers.go +++ b/internal/providers/providers.go @@ -52,7 +52,7 @@ func (providers *Providers) Init() { ClientID: providers.Config.GenericClientId, ClientSecret: providers.Config.GenericClientSecret, RedirectURL: fmt.Sprintf("%s/api/oauth/callback/generic", providers.Config.AppURL), - Scopes: []string{providers.Config.GenericScopes}, + Scopes: providers.Config.GenericScopes, Endpoint: oauth2.Endpoint{ AuthURL: providers.Config.GenericAuthURL, TokenURL: providers.Config.GenericTokenURL, diff --git a/internal/types/types.go b/internal/types/types.go index f82b19c..8dcc94b 100644 --- a/internal/types/types.go +++ b/internal/types/types.go @@ -63,7 +63,7 @@ type OAuthConfig struct { GoogleClientSecret string GenericClientId string GenericClientSecret string - GenericScopes string + GenericScopes []string GenericAuthURL string GenericTokenURL string GenericUserURL string diff --git a/internal/utils/utils.go b/internal/utils/utils.go index 1eaf38a..6d4bc84 100644 --- a/internal/utils/utils.go +++ b/internal/utils/utils.go @@ -75,9 +75,9 @@ func ParseFileToLine(content string) string { return strings.Join(users, ",") } -func ParseWhitelist(whitelist string) []string { - if whitelist == "" { +func ParseCommaString(str string) []string { + if str == "" { return []string{} } - return strings.Split(whitelist, ",") + return strings.Split(str, ",") }