diff options
author | techknowlogick <techknowlogick@gitea.io> | 2019-09-12 22:15:36 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-09-12 22:15:36 -0400 |
commit | 2837563147d18dba263ed4c7a1b87571474220c4 (patch) | |
tree | 653d95c0538e1e32853ebbc52ee1487994159715 /modules/auth | |
parent | cff0787759304fcebf1c0e21709158e7d4f1967f (diff) | |
download | gitea-2837563147d18dba263ed4c7a1b87571474220c4.tar.gz gitea-2837563147d18dba263ed4c7a1b87571474220c4.zip |
oauth2 with remote Gitea - Fix #8093 (#8149)
Diffstat (limited to 'modules/auth')
-rw-r--r-- | modules/auth/oauth2/oauth2.go | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/modules/auth/oauth2/oauth2.go b/modules/auth/oauth2/oauth2.go index a2d7116211..de2efd0463 100644 --- a/modules/auth/oauth2/oauth2.go +++ b/modules/auth/oauth2/oauth2.go @@ -19,6 +19,7 @@ import ( "github.com/markbates/goth/providers/discord" "github.com/markbates/goth/providers/dropbox" "github.com/markbates/goth/providers/facebook" + "github.com/markbates/goth/providers/gitea" "github.com/markbates/goth/providers/github" "github.com/markbates/goth/providers/gitlab" "github.com/markbates/goth/providers/gplus" @@ -175,6 +176,22 @@ func createProvider(providerName, providerType, clientID, clientSecret, openIDCo provider = twitter.NewAuthenticate(clientID, clientSecret, callbackURL) case "discord": provider = discord.New(clientID, clientSecret, callbackURL, discord.ScopeIdentify, discord.ScopeEmail) + case "gitea": + authURL := gitea.AuthURL + tokenURL := gitea.TokenURL + profileURL := gitea.ProfileURL + if customURLMapping != nil { + if len(customURLMapping.AuthURL) > 0 { + authURL = customURLMapping.AuthURL + } + if len(customURLMapping.TokenURL) > 0 { + tokenURL = customURLMapping.TokenURL + } + if len(customURLMapping.ProfileURL) > 0 { + profileURL = customURLMapping.ProfileURL + } + } + provider = gitea.NewCustomisedURL(clientID, clientSecret, callbackURL, authURL, tokenURL, profileURL) } // always set the name if provider is created so we can support multiple setups of 1 provider @@ -192,6 +209,8 @@ func GetDefaultTokenURL(provider string) string { return github.TokenURL case "gitlab": return gitlab.TokenURL + case "gitea": + return gitea.TokenURL } return "" } @@ -203,6 +222,8 @@ func GetDefaultAuthURL(provider string) string { return github.AuthURL case "gitlab": return gitlab.AuthURL + case "gitea": + return gitea.AuthURL } return "" } @@ -214,6 +235,8 @@ func GetDefaultProfileURL(provider string) string { return github.ProfileURL case "gitlab": return gitlab.ProfileURL + case "gitea": + return gitea.ProfileURL } return "" } |