diff options
author | zeripath <art27@cantab.net> | 2021-02-26 03:20:58 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-02-25 22:20:58 -0500 |
commit | 50208e903ae9aa931db3d93bde7032e766687cae (patch) | |
tree | 070a31897c52ef9cadd04ec4518831918a7fcfa5 /models | |
parent | 97e5a1d7b396844fa48a97f76185f004b1a2a7d0 (diff) | |
download | gitea-50208e903ae9aa931db3d93bde7032e766687cae.tar.gz gitea-50208e903ae9aa931db3d93bde7032e766687cae.zip |
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 <art27@cantab.net>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
Diffstat (limited to 'models')
-rw-r--r-- | models/oauth2.go | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/models/oauth2.go b/models/oauth2.go index 241e11a44d..201610938a 100644 --- a/models/oauth2.go +++ b/models/oauth2.go @@ -8,6 +8,7 @@ import ( "sort" "code.gitea.io/gitea/modules/auth/oauth2" + "code.gitea.io/gitea/modules/log" ) // OAuth2Provider describes the display values of a single OAuth2 provider @@ -145,7 +146,12 @@ func initOAuth2LoginSources() error { oAuth2Config := source.OAuth2() err := oauth2.RegisterProvider(source.Name, oAuth2Config.Provider, oAuth2Config.ClientID, oAuth2Config.ClientSecret, oAuth2Config.OpenIDConnectAutoDiscoveryURL, oAuth2Config.CustomURLMapping) if err != nil { - return err + log.Critical("Unable to register source: %s due to Error: %v. This source will be disabled.", source.Name, err) + source.IsActived = false + if err = UpdateSource(source); err != nil { + log.Critical("Unable to update source %s to disable it. Error: %v", err) + return err + } } } return nil |