Skip to content

Commit

Permalink
Disable broken OAuth2 providers at startup (go-gitea#14802)
Browse files Browse the repository at this point in the history
Backport go-gitea#14802

Instead of causing a log.Fatal, we should handle broken OAuth2
providers by disabling them.

Fix go-gitea#8930

Signed-off-by: Andrew Thornton <art27@cantab.net>

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
  • Loading branch information
zeripath and techknowlogick committed Feb 26, 2021
1 parent 77ce089 commit 60af0bd
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion models/oauth2.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -135,7 +136,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
Expand Down

0 comments on commit 60af0bd

Please sign in to comment.