mirror of
https://github.com/steveiliop56/tinyauth.git
synced 2025-10-28 04:35:40 +00:00
fix: split generic scopes string to array
This commit is contained in:
@@ -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,
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -63,7 +63,7 @@ type OAuthConfig struct {
|
||||
GoogleClientSecret string
|
||||
GenericClientId string
|
||||
GenericClientSecret string
|
||||
GenericScopes string
|
||||
GenericScopes []string
|
||||
GenericAuthURL string
|
||||
GenericTokenURL string
|
||||
GenericUserURL string
|
||||
|
||||
@@ -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, ",")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user