summaryrefslogtreecommitdiffstats
path: root/services/auth/source/oauth2/init.go
diff options
context:
space:
mode:
Diffstat (limited to 'services/auth/source/oauth2/init.go')
-rw-r--r--services/auth/source/oauth2/init.go17
1 files changed, 11 insertions, 6 deletions
diff --git a/services/auth/source/oauth2/init.go b/services/auth/source/oauth2/init.go
index f797fd7fd4..64328aa381 100644
--- a/services/auth/source/oauth2/init.go
+++ b/services/auth/source/oauth2/init.go
@@ -6,6 +6,7 @@ package oauth2
import (
"net/http"
+ "sync"
"code.gitea.io/gitea/models"
"code.gitea.io/gitea/modules/log"
@@ -15,6 +16,8 @@ import (
"github.com/markbates/goth/gothic"
)
+var gothRWMutex = sync.RWMutex{}
+
// SessionTableName is the table name that OAuth2 will use to store things
const SessionTableName = "oauth2_session"
@@ -42,6 +45,10 @@ func Init() error {
// Note, when using the FilesystemStore only the session.ID is written to a browser cookie, so this is explicit for the storage on disk
store.MaxLength(setting.OAuth2.MaxTokenLength)
+
+ // Lock our mutex
+ gothRWMutex.Lock()
+
gothic.Store = store
gothic.SetState = func(req *http.Request) string {
@@ -52,6 +59,9 @@ func Init() error {
return req.Header.Get(ProviderHeaderKey), nil
}
+ // Unlock our mutex
+ gothRWMutex.Unlock()
+
return initOAuth2LoginSources()
}
@@ -71,12 +81,7 @@ func initOAuth2LoginSources() error {
}
err := oauth2Source.RegisterSource()
if err != nil {
- log.Critical("Unable to register source: %s due to Error: %v. This source will be disabled.", source.Name, err)
- source.IsActive = false
- if err = models.UpdateSource(source); err != nil {
- log.Critical("Unable to update source %s to disable it. Error: %v", err)
- return err
- }
+ log.Critical("Unable to register source: %s due to Error: %v.", source.Name, err)
}
}
return nil