Skip to content

Commit 50208e9

Browse files
Disable broken OAuth2 providers at startup (#14802)
Instead of causing a log.Fatal, we should handle broken OAuth2 providers by disabling them. Fix #8930 Signed-off-by: Andrew Thornton <[email protected]> Co-authored-by: techknowlogick <[email protected]>
1 parent 97e5a1d commit 50208e9

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

models/oauth2.go

+7-1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88
"sort"
99

1010
"code.gitea.io/gitea/modules/auth/oauth2"
11+
"code.gitea.io/gitea/modules/log"
1112
)
1213

1314
// OAuth2Provider describes the display values of a single OAuth2 provider
@@ -145,7 +146,12 @@ func initOAuth2LoginSources() error {
145146
oAuth2Config := source.OAuth2()
146147
err := oauth2.RegisterProvider(source.Name, oAuth2Config.Provider, oAuth2Config.ClientID, oAuth2Config.ClientSecret, oAuth2Config.OpenIDConnectAutoDiscoveryURL, oAuth2Config.CustomURLMapping)
147148
if err != nil {
148-
return err
149+
log.Critical("Unable to register source: %s due to Error: %v. This source will be disabled.", source.Name, err)
150+
source.IsActived = false
151+
if err = UpdateSource(source); err != nil {
152+
log.Critical("Unable to update source %s to disable it. Error: %v", err)
153+
return err
154+
}
149155
}
150156
}
151157
return nil

0 commit comments

Comments
 (0)