Skip to content

Commit 90bf1e7

Browse files
Disable broken OAuth2 providers at startup (#14802) (#14811)
Backport #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 77ce089 commit 90bf1e7

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

models/oauth2.go

Lines changed: 7 additions & 1 deletion
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
@@ -135,7 +136,12 @@ func initOAuth2LoginSources() error {
135136
oAuth2Config := source.OAuth2()
136137
err := oauth2.RegisterProvider(source.Name, oAuth2Config.Provider, oAuth2Config.ClientID, oAuth2Config.ClientSecret, oAuth2Config.OpenIDConnectAutoDiscoveryURL, oAuth2Config.CustomURLMapping)
137138
if err != nil {
138-
return err
139+
log.Critical("Unable to register source: %s due to Error: %v. This source will be disabled.", source.Name, err)
140+
source.IsActived = false
141+
if err = UpdateSource(source); err != nil {
142+
log.Critical("Unable to update source %s to disable it. Error: %v", err)
143+
return err
144+
}
139145
}
140146
}
141147
return nil

0 commit comments

Comments
 (0)