Skip to content

Commit 6d34f62

Browse files
dont use map per feedback
1 parent 587bf92 commit 6d34f62

File tree

1 file changed

+15
-6
lines changed

1 file changed

+15
-6
lines changed

services/auth/source/oauth2/providers.go

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -75,10 +75,19 @@ func (p *AuthSourceProvider) IconHTML(size int) template.HTML {
7575
// value is used to store display data
7676
var gothProviders = map[string]GothProvider{}
7777

78-
var azureProviders = map[string]bool{
79-
"azuread": true,
80-
"microsoftonline": true,
81-
"azureadv2": true,
78+
var azureProviders = []string{
79+
"azuread",
80+
"microsoftonline",
81+
"azureadv2",
82+
}
83+
84+
func isAzureProvider(providerName string) bool {
85+
for _, azureProvider := range azureProviders {
86+
if providerName == azureProvider {
87+
return true
88+
}
89+
}
90+
return false
8291
}
8392

8493
// RegisterGothProvider registers a GothProvider
@@ -100,7 +109,7 @@ func hasExistingAzureADAuthSources(ctx context.Context) bool {
100109

101110
for _, source := range authSources {
102111
if oauth2Cfg, ok := source.Cfg.(*Source); ok {
103-
if azureProviders[oauth2Cfg.Provider] {
112+
if isAzureProvider(oauth2Cfg.Provider) {
104113
return true
105114
}
106115
}
@@ -123,7 +132,7 @@ func GetSupportedOAuth2ProvidersWithContext(ctx context.Context) []Provider {
123132
hasExistingAzure := hasExistingAzureADAuthSources(ctx)
124133

125134
for _, provider := range gothProviders {
126-
if azureProviders[provider.Name()] && !hasExistingAzure {
135+
if isAzureProvider(provider.Name()) && !hasExistingAzure {
127136
continue
128137
}
129138
providers = append(providers, provider)

0 commit comments

Comments
 (0)