Skip to content

Commit

Permalink
migrate gplus to google oauth2 provider (#7885)
Browse files Browse the repository at this point in the history
* migrate gplus to google oauth2 provider. this still provides support for old gplus connections.

* Update models/oauth2.go

Co-Authored-By: Antoine GIRARD <sapk@users.noreply.github.com>

* make vendor
  • Loading branch information
techknowlogick authored and sapk committed Sep 14, 2019
1 parent 107d57a commit 7a8e299
Show file tree
Hide file tree
Showing 39 changed files with 3,992 additions and 63 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@ require (
github.com/lib/pq v1.2.0
github.com/lunny/dingtalk_webhook v0.0.0-20171025031554-e3534c89ef96
github.com/lunny/levelqueue v0.0.0-20190217115915-02b525a4418e
github.com/markbates/goth v1.56.0
github.com/mailru/easyjson v0.7.0 // indirect
github.com/markbates/goth v1.56.0
github.com/mattn/go-isatty v0.0.7
github.com/mattn/go-oci8 v0.0.0-20190320171441-14ba190cf52d // indirect
github.com/mattn/go-sqlite3 v1.11.0
Expand Down
2 changes: 1 addition & 1 deletion models/oauth2.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ var OAuth2Providers = map[string]OAuth2Provider{
ProfileURL: oauth2.GetDefaultProfileURL("gitlab"),
},
},
"gplus": {Name: "gplus", DisplayName: "Google+", Image: "/img/auth/google_plus.png"},
"gplus": {Name: "gplus", DisplayName: "Google", Image: "/img/auth/google.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"},
Expand Down
6 changes: 3 additions & 3 deletions modules/auth/oauth2/oauth2.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import (
"github.com/markbates/goth/providers/gitea"
"github.com/markbates/goth/providers/github"
"github.com/markbates/goth/providers/gitlab"
"github.com/markbates/goth/providers/gplus"
"github.com/markbates/goth/providers/google"
"github.com/markbates/goth/providers/openidConnect"
"github.com/markbates/goth/providers/twitter"
"github.com/satori/go.uuid"
Expand Down Expand Up @@ -166,8 +166,8 @@ func createProvider(providerName, providerType, clientID, clientSecret, openIDCo
}
}
provider = gitlab.NewCustomisedURL(clientID, clientSecret, callbackURL, authURL, tokenURL, profileURL, "read_user")
case "gplus":
provider = gplus.New(clientID, clientSecret, callbackURL, "email")
case "gplus": // named gplus due to legacy gplus -> google migration (Google killed Google+). This ensures old connections still work
provider = google.New(clientID, clientSecret, callbackURL)
case "openidConnect":
if provider, err = openidConnect.New(clientID, clientSecret, callbackURL, openIDConnectAutoDiscoveryURL); err != nil {
log.Warn("Failed to create OpenID Connect Provider with name '%s' with url '%s': %v", providerName, openIDConnectAutoDiscoveryURL, err)
Expand Down
Binary file added public/img/auth/google.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed public/img/auth/google_plus.png
Binary file not shown.
2 changes: 1 addition & 1 deletion templates/admin/auth/new.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@
<span>{{.i18n.Tr "admin.auths.tip.github"}}</span>
<li>GitLab</li>
<span>{{.i18n.Tr "admin.auths.tip.gitlab"}}</span>
<li>Google+</li>
<li>Google</li>
<span>{{.i18n.Tr "admin.auths.tip.google_plus"}}</span>
<li>OpenID Connect</li>
<span>{{.i18n.Tr "admin.auths.tip.openid_connect"}}</span>
Expand Down
Loading

0 comments on commit 7a8e299

Please sign in to comment.