Skip to content

Commit 5c44f75

Browse files
Discord Oauth2 support (#4476)
* add discord auth * add vendor for discord * fix syntax error * make fmt * update version of goth in use * update markbates/goth
1 parent beab2df commit 5c44f75

File tree

10 files changed

+308
-26
lines changed

10 files changed

+308
-26
lines changed

Gopkg.lock

Lines changed: 5 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

models/oauth2.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ var OAuth2Providers = map[string]OAuth2Provider{
4343
"gplus": {Name: "gplus", DisplayName: "Google+", Image: "/img/auth/google_plus.png"},
4444
"openidConnect": {Name: "openidConnect", DisplayName: "OpenID Connect", Image: "/img/auth/openid_connect.png"},
4545
"twitter": {Name: "twitter", DisplayName: "Twitter", Image: "/img/auth/twitter.png"},
46+
"discord": {Name: "discord", DisplayName: "Discord", Image: "/img/auth/discord.png"},
4647
}
4748

4849
// OAuth2DefaultCustomURLMappings contains the map of default URL's for OAuth2 providers that are allowed to have custom urls

modules/auth/oauth2/oauth2.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import (
1616
"github.com/markbates/goth"
1717
"github.com/markbates/goth/gothic"
1818
"github.com/markbates/goth/providers/bitbucket"
19+
"github.com/markbates/goth/providers/discord"
1920
"github.com/markbates/goth/providers/dropbox"
2021
"github.com/markbates/goth/providers/facebook"
2122
"github.com/markbates/goth/providers/github"
@@ -172,6 +173,8 @@ func createProvider(providerName, providerType, clientID, clientSecret, openIDCo
172173
}
173174
case "twitter":
174175
provider = twitter.NewAuthenticate(clientID, clientSecret, callbackURL)
176+
case "discord":
177+
provider = discord.New(clientID, clientSecret, callbackURL, discord.ScopeIdentify, discord.ScopeEmail)
175178
}
176179

177180
// always set the name if provider is created so we can support multiple setups of 1 provider

options/locale/locale_en-US.ini

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1523,6 +1523,7 @@ auths.tip.gitlab = Register a new application on https://gitlab.com/profile/appl
15231523
auths.tip.google_plus = Obtain OAuth2 client credentials from the Google API console at https://console.developers.google.com/
15241524
auths.tip.openid_connect = Use the OpenID Connect Discovery URL (<server>/.well-known/openid-configuration) to specify the endpoints
15251525
auths.tip.twitter = Go to https://dev.twitter.com/apps, create an application and ensure that the “Allow this application to be used to Sign in with Twitter” option is enabled
1526+
auths.tip.discord = Register a new application on https://discordapp.com/developers/applications/me
15261527
auths.edit = Edit Authentication Source
15271528
auths.activated = This Authentication Source is Activated
15281529
auths.new_success = The authentication '%s' has been added.

public/img/auth/discord.png

1.52 KB
Loading

templates/admin/auth/new.tmpl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,8 @@
108108
<span>{{.i18n.Tr "admin.auths.tip.openid_connect"}}</span>
109109
<li>Twitter</li>
110110
<span>{{.i18n.Tr "admin.auths.tip.twitter"}}</span>
111+
<li>Discord</li>
112+
<span>{{.i18n.Tr "admin.auths.tip.discord"}}</span>
111113
</div>
112114
</div>
113115
</div>

vendor/github.com/markbates/goth/gothic/gothic.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/github.com/markbates/goth/providers/discord/discord.go

Lines changed: 210 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/github.com/markbates/goth/providers/discord/session.go

Lines changed: 65 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)