-
-
Notifications
You must be signed in to change notification settings - Fork 6k
Remove deprecated auth sources #35272
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
techknowlogick
wants to merge
9
commits into
go-gitea:main
Choose a base branch
from
techknowlogick:deprecate-azure-ad-auth
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 3 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
ebb8c93
Remove deprecated auth sources
techknowlogick f63f49c
Merge branch 'main' into deprecate-azure-ad-auth
techknowlogick 57b24be
Merge branch 'main' into deprecate-azure-ad-auth
techknowlogick 441b0ab
Merge remote-tracking branch 'upstream/main' into deprecate-azure-ad-…
techknowlogick 931044c
reduce duplication
techknowlogick 587bf92
Merge branch 'main' into deprecate-azure-ad-auth
techknowlogick 6d34f62
dont use map per feedback
techknowlogick c9feca8
fix lint
techknowlogick 7a8ac61
Merge branch 'main' into deprecate-azure-ad-auth
techknowlogick File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -83,13 +83,55 @@ func RegisterGothProvider(provider GothProvider) { | |
gothProviders[provider.Name()] = provider | ||
} | ||
|
||
// 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, | ||
}) | ||
if err != nil { | ||
return false | ||
} | ||
|
||
for _, source := range authSources { | ||
if oauth2Cfg, ok := source.Cfg.(*Source); ok { | ||
if azureProviders[oauth2Cfg.Provider] { | ||
return true | ||
} | ||
} | ||
} | ||
return false | ||
} | ||
|
||
// GetSupportedOAuth2Providers returns the map of unconfigured OAuth2 providers | ||
// key is used as technical name (like in the callbackURL) | ||
// values to display | ||
// Note: Azure AD providers (azuread, microsoftonline, azureadv2) are filtered out | ||
// unless they already exist in the system to encourage use of OpenID Connect | ||
func GetSupportedOAuth2Providers() []Provider { | ||
return GetSupportedOAuth2ProvidersWithContext(context.Background()) | ||
} | ||
|
||
// GetSupportedOAuth2ProvidersWithContext returns the list of supported OAuth2 providers with context for filtering | ||
func GetSupportedOAuth2ProvidersWithContext(ctx context.Context) []Provider { | ||
providers := make([]Provider, 0, len(gothProviders)) | ||
hasExistingAzure := hasExistingAzureADAuthSources(ctx) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I mean existAuthSources := getExistingAzureADAuthSources(ctx)
for _, provider := range gothProviders {
if isAzureProvider(provider.Name()) && !slices.Contains(existAuthSources, provider.Name()) {
continue
} |
||
|
||
azureProviders := map[string]bool{ | ||
"azuread": true, | ||
"microsoftonline": true, | ||
"azureadv2": true, | ||
} | ||
|
||
techknowlogick marked this conversation as resolved.
Show resolved
Hide resolved
|
||
for _, provider := range gothProviders { | ||
if azureProviders[provider.Name()] && !hasExistingAzure { | ||
continue | ||
} | ||
providers = append(providers, provider) | ||
} | ||
sort.Slice(providers, func(i, j int) bool { | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.