forked from forgejo/forgejo
parent
ae419fa494
commit
76a85a4ce9
64 changed files with 250 additions and 242 deletions
|
@ -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 {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue