Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
reduce duplication
  • Loading branch information
techknowlogick committed Aug 15, 2025
commit 931044c38f289cc9e5698b707f41ef91394989f5
18 changes: 6 additions & 12 deletions services/auth/source/oauth2/providers.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,12 @@ func (p *AuthSourceProvider) IconHTML(size int) template.HTML {
// value is used to store display data
var gothProviders = map[string]GothProvider{}

var azureProviders = map[string]bool{
"azuread": true,
"microsoftonline": true,
"azureadv2": true,
}

// RegisterGothProvider registers a GothProvider
func RegisterGothProvider(provider GothProvider) {
if _, has := gothProviders[provider.Name()]; has {
Expand All @@ -85,12 +91,6 @@ func RegisterGothProvider(provider GothProvider) {

// hasExistingAzureADAuthSources checks if there are any existing Azure AD auth sources configured
func hasExistingAzureADAuthSources(ctx context.Context) bool {
azureProviders := map[string]bool{
"azuread": true,
"microsoftonline": true,
"azureadv2": true,
}

authSources, err := db.Find[auth.Source](ctx, auth.FindSourcesOptions{
LoginType: auth.OAuth2,
})
Expand Down Expand Up @@ -122,12 +122,6 @@ func GetSupportedOAuth2ProvidersWithContext(ctx context.Context) []Provider {
providers := make([]Provider, 0, len(gothProviders))
hasExistingAzure := hasExistingAzureADAuthSources(ctx)

azureProviders := map[string]bool{
"azuread": true,
"microsoftonline": true,
"azureadv2": true,
}

for _, provider := range gothProviders {
if azureProviders[provider.Name()] && !hasExistingAzure {
continue
Expand Down