summaryrefslogtreecommitdiffstats
path: root/modules/auth
diff options
context:
space:
mode:
authorDivyam Bhasin <divbest99@gmail.com>2020-10-25 14:21:49 -0400
committerGitHub <noreply@github.com>2020-10-25 14:21:49 -0400
commit7974b3418350c180df70111da611047f09122fa9 (patch)
tree869fad1ab88c8deca8f6e1eba01cb2b0a47a539e /modules/auth
parentf565cf5dcfa6a674eff2a7b3d47f47c77c6ed9d7 (diff)
downloadgitea-7974b3418350c180df70111da611047f09122fa9.tar.gz
gitea-7974b3418350c180df70111da611047f09122fa9.zip
#12897 - add mastodon provider (#13293)
* added mastodon provider to oauth code * changed go.mod and vendor/modules.txt to add updated goth * vendored mastodon and new goth * committing result of go mod tidy && go mod vendor * added pic and mastodon to oauth models * handled instance url * applied lafriks suggestion * Update web_src/js/index.js Co-authored-by: techknowlogick <matti@mdranta.net> Co-authored-by: techknowlogick <techknowlogick@gitea.io> Co-authored-by: Lauris BH <lauris@nix.lv> Co-authored-by: techknowlogick <matti@mdranta.net>
Diffstat (limited to 'modules/auth')
-rw-r--r--modules/auth/oauth2/oauth2.go9
1 files changed, 9 insertions, 0 deletions
diff --git a/modules/auth/oauth2/oauth2.go b/modules/auth/oauth2/oauth2.go
index 2c982e1dca..f69bc61d75 100644
--- a/modules/auth/oauth2/oauth2.go
+++ b/modules/auth/oauth2/oauth2.go
@@ -23,6 +23,7 @@ import (
"github.com/markbates/goth/providers/github"
"github.com/markbates/goth/providers/gitlab"
"github.com/markbates/goth/providers/google"
+ "github.com/markbates/goth/providers/mastodon"
"github.com/markbates/goth/providers/nextcloud"
"github.com/markbates/goth/providers/openidConnect"
"github.com/markbates/goth/providers/twitter"
@@ -213,6 +214,12 @@ func createProvider(providerName, providerType, clientID, clientSecret, openIDCo
case "yandex":
// See https://tech.yandex.com/passport/doc/dg/reference/response-docpage/
provider = yandex.New(clientID, clientSecret, callbackURL, "login:email", "login:info", "login:avatar")
+ case "mastodon":
+ instanceURL := mastodon.InstanceURL
+ if customURLMapping != nil && len(customURLMapping.AuthURL) > 0 {
+ instanceURL = customURLMapping.AuthURL
+ }
+ provider = mastodon.NewCustomisedURL(clientID, clientSecret, callbackURL, instanceURL)
}
// always set the name if provider is created so we can support multiple setups of 1 provider
@@ -249,6 +256,8 @@ func GetDefaultAuthURL(provider string) string {
return gitea.AuthURL
case "nextcloud":
return nextcloud.AuthURL
+ case "mastodon":
+ return mastodon.InstanceURL
}
return ""
}