diff options
author | JakobDev <jakobdev@gmx.de> | 2023-10-14 10:37:24 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-10-14 08:37:24 +0000 |
commit | 76a85a4ce90fead1eb2b743a42b41617b4592889 (patch) | |
tree | ef172bbbc48c24e0d95cd5c689426bad16205a69 /services/auth/source | |
parent | ae419fa49403537725c806a5f3f1e5b274f52eb7 (diff) | |
download | gitea-76a85a4ce90fead1eb2b743a42b41617b4592889.tar.gz gitea-76a85a4ce90fead1eb2b743a42b41617b4592889.zip |
Final round of `db.DefaultContext` refactor (#27587)
Last part of #27065
Diffstat (limited to 'services/auth/source')
-rw-r--r-- | services/auth/source/oauth2/init.go | 13 | ||||
-rw-r--r-- | services/auth/source/oauth2/providers.go | 5 |
2 files changed, 10 insertions, 8 deletions
diff --git a/services/auth/source/oauth2/init.go b/services/auth/source/oauth2/init.go index 32fe545c90..cfaddaa35d 100644 --- a/services/auth/source/oauth2/init.go +++ b/services/auth/source/oauth2/init.go @@ -4,6 +4,7 @@ package oauth2 import ( + "context" "encoding/gob" "net/http" "sync" @@ -26,7 +27,7 @@ const UsersStoreKey = "gitea-oauth2-sessions" const ProviderHeaderKey = "gitea-oauth2-provider" // Init initializes the oauth source -func Init() error { +func Init(ctx context.Context) error { if err := InitSigningKey(); err != nil { return err } @@ -51,18 +52,18 @@ func Init() error { // Unlock our mutex gothRWMutex.Unlock() - return initOAuth2Sources() + return initOAuth2Sources(ctx) } // ResetOAuth2 clears existing OAuth2 providers and loads them from DB -func ResetOAuth2() error { +func ResetOAuth2(ctx context.Context) error { ClearProviders() - return initOAuth2Sources() + return initOAuth2Sources(ctx) } // initOAuth2Sources is used to load and register all active OAuth2 providers -func initOAuth2Sources() error { - authSources, _ := auth.GetActiveOAuth2ProviderSources() +func initOAuth2Sources(ctx context.Context) error { + authSources, _ := auth.GetActiveOAuth2ProviderSources(ctx) for _, source := range authSources { oauth2Source, ok := source.Cfg.(*Source) if !ok { diff --git a/services/auth/source/oauth2/providers.go b/services/auth/source/oauth2/providers.go index e3a0cb0335..cd158614a2 100644 --- a/services/auth/source/oauth2/providers.go +++ b/services/auth/source/oauth2/providers.go @@ -4,6 +4,7 @@ package oauth2 import ( + "context" "errors" "fmt" "html" @@ -97,10 +98,10 @@ func GetOAuth2Providers() []Provider { // GetActiveOAuth2Providers returns the map of configured active OAuth2 providers // key is used as technical name (like in the callbackURL) // values to display -func GetActiveOAuth2Providers() ([]string, map[string]Provider, error) { +func GetActiveOAuth2Providers(ctx context.Context) ([]string, map[string]Provider, error) { // Maybe also separate used and unused providers so we can force the registration of only 1 active provider for each type - authSources, err := auth.GetActiveOAuth2ProviderSources() + authSources, err := auth.GetActiveOAuth2ProviderSources(ctx) if err != nil { return nil, nil, err } |