Skip to content

Commit 931044c

Browse files
reduce duplication
1 parent 441b0ab commit 931044c

File tree

1 file changed

+6
-12
lines changed

1 file changed

+6
-12
lines changed

services/auth/source/oauth2/providers.go

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,12 @@ 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,
82+
}
83+
7884
// RegisterGothProvider registers a GothProvider
7985
func RegisterGothProvider(provider GothProvider) {
8086
if _, has := gothProviders[provider.Name()]; has {
@@ -85,12 +91,6 @@ func RegisterGothProvider(provider GothProvider) {
8591

8692
// hasExistingAzureADAuthSources checks if there are any existing Azure AD auth sources configured
8793
func hasExistingAzureADAuthSources(ctx context.Context) bool {
88-
azureProviders := map[string]bool{
89-
"azuread": true,
90-
"microsoftonline": true,
91-
"azureadv2": true,
92-
}
93-
9494
authSources, err := db.Find[auth.Source](ctx, auth.FindSourcesOptions{
9595
LoginType: auth.OAuth2,
9696
})
@@ -122,12 +122,6 @@ func GetSupportedOAuth2ProvidersWithContext(ctx context.Context) []Provider {
122122
providers := make([]Provider, 0, len(gothProviders))
123123
hasExistingAzure := hasExistingAzureADAuthSources(ctx)
124124

125-
azureProviders := map[string]bool{
126-
"azuread": true,
127-
"microsoftonline": true,
128-
"azureadv2": true,
129-
}
130-
131125
for _, provider := range gothProviders {
132126
if azureProviders[provider.Name()] && !hasExistingAzure {
133127
continue

0 commit comments

Comments
 (0)