add discord auth

This commit is contained in:
Matti Ranta 2018-07-19 17:56:08 -04:00
parent 1e2da5d396
commit 9eee484338
No known key found for this signature in database
GPG Key ID: D9B5613BEB813F99
5 changed files with 7 additions and 0 deletions

View File

@ -43,6 +43,7 @@ var OAuth2Providers = map[string]OAuth2Provider{
"gplus": {Name: "gplus", DisplayName: "Google+", Image: "/img/auth/google_plus.png"},
"openidConnect": {Name: "openidConnect", DisplayName: "OpenID Connect", Image: "/img/auth/openid_connect.png"},
"twitter": {Name: "twitter", DisplayName: "Twitter", Image: "/img/auth/twitter.png"},
"discord": {Name: "discord", DisplayName: "Discord", Image: "/img/auth/discord.png"},
}
// OAuth2DefaultCustomURLMappings contains the map of default URL's for OAuth2 providers that are allowed to have custom urls

View File

@ -23,6 +23,7 @@ import (
"github.com/markbates/goth/providers/gplus"
"github.com/markbates/goth/providers/openidConnect"
"github.com/markbates/goth/providers/twitter"
"github.com/markbates/goth/providers/discord"
"github.com/satori/go.uuid"
)
@ -172,6 +173,8 @@ func createProvider(providerName, providerType, clientID, clientSecret, openIDCo
}
case "twitter":
provider = twitter.NewAuthenticate(clientID, clientSecret, callbackURL)
case "discord":
provider = discord.New(clientID, clientSecret, callbackURL, discord.ScopeIdentify, discord.ScopeEmail),
}
// always set the name if provider is created so we can support multiple setups of 1 provider

View File

@ -1458,6 +1458,7 @@ auths.tip.gitlab = Register a new application on https://gitlab.com/profile/appl
auths.tip.google_plus = Obtain OAuth2 client credentials from the Google API console at https://console.developers.google.com/
auths.tip.openid_connect = Use the OpenID Connect Discovery URL (<server>/.well-known/openid-configuration) to specify the endpoints
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
auths.tip.discord = Register a new application on https://discordapp.com/developers/applications/me
auths.edit = Edit Authentication Source
auths.activated = This Authentication Source is Activated
auths.new_success = The authentication '%s' has been added.

BIN
public/img/auth/discord.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

View File

@ -108,6 +108,8 @@
<span>{{.i18n.Tr "admin.auths.tip.openid_connect"}}</span>
<li>Twitter</li>
<span>{{.i18n.Tr "admin.auths.tip.twitter"}}</span>
<li>Discord</li>
<span>{{.i18n.Tr "admin.auths.tip.discord"}}</span>
</div>
</div>
</div>