aboutsummaryrefslogtreecommitdiffstats
path: root/models
diff options
context:
space:
mode:
authorDaniil Pankratov <mobigod0@gmail.com>2020-12-24 22:47:17 +0300
committerGitHub <noreply@github.com>2020-12-24 19:47:17 +0000
commit5a94db37ed16b253bf6e43ae6337f3a3c21f6d70 (patch)
tree0f4f27450e423eae290a801a325bbd42c17d887c /models
parentbdeccc36886d6df4f2a8fce9e5f71e866e9902fc (diff)
downloadgitea-5a94db37ed16b253bf6e43ae6337f3a3c21f6d70.tar.gz
gitea-5a94db37ed16b253bf6e43ae6337f3a3c21f6d70.zip
Fix creating OAuth2 auth source from CLI (#14116)
Fix creation OAuth2 auth source from CLI. Fix #8356 Co-authored-by: Daniil Pankratov <daniil.pankratov@t-systems.com>
Diffstat (limited to 'models')
-rw-r--r--models/oauth2.go12
1 files changed, 11 insertions, 1 deletions
diff --git a/models/oauth2.go b/models/oauth2.go
index 65d62fdb61..27668d5eec 100644
--- a/models/oauth2.go
+++ b/models/oauth2.go
@@ -125,8 +125,18 @@ func InitOAuth2() error {
if err := oauth2.Init(x); err != nil {
return err
}
- loginSources, _ := GetActiveOAuth2ProviderLoginSources()
+ return initOAuth2LoginSources()
+}
+// ResetOAuth2 clears existing OAuth2 providers and loads them from DB
+func ResetOAuth2() error {
+ oauth2.ClearProviders()
+ return initOAuth2LoginSources()
+}
+
+// initOAuth2LoginSources is used to load and register all active OAuth2 providers
+func initOAuth2LoginSources() error {
+ loginSources, _ := GetActiveOAuth2ProviderLoginSources()
for _, source := range loginSources {
oAuth2Config := source.OAuth2()
err := oauth2.RegisterProvider(source.Name, oAuth2Config.Provider, oAuth2Config.ClientID, oAuth2Config.ClientSecret, oAuth2Config.OpenIDConnectAutoDiscoveryURL, oAuth2Config.CustomURLMapping)