Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Additional OAuth2 providers #1010

Merged
merged 27 commits into from
May 1, 2017

Conversation

willemvd
Copy link
Contributor

@willemvd willemvd commented Feb 22, 2017

This is a followup on #679 (this PR is based on the merged #679 master) which only included GitHub as an OAuth2 provider.

For now the following providers are implemented (incl signin image and tip text in admin/auths/new):
Google+
GitLab
Bitbucket
Twitter
Facebook
Dropbox
OpenID Connect

For GitLab and Github it is now possible to change the default urls to custom urls, this means you can connect them to your own private/local/on-premise/enterprise installation

I will add and test new providers on request in this PR (or on gitter?), list of possible providers can be found at : https://github.com/markbates/goth/#supported-providers

@lunny lunny added this to the 1.2.0 milestone Feb 22, 2017
@lunny lunny added the type/feature Completely new functionality. Can only be merged if feature freeze is not active. label Feb 22, 2017
@lunny
Copy link
Member

lunny commented Feb 22, 2017

build failed.

@tboerger tboerger added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label Feb 22, 2017
@willemvd
Copy link
Contributor Author

fixed

@@ -23,6 +23,7 @@ import (
"code.gitea.io/gitea/modules/auth/pam"
"code.gitea.io/gitea/modules/log"
"code.gitea.io/gitea/modules/auth/oauth2"
"sort"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Move local package to top

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done, changed to goimports style

"github.com/markbates/goth/providers/facebook"
"github.com/markbates/goth/providers/dropbox"
"github.com/markbates/goth/providers/openidConnect"
"math"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done, changed to goimports style

@appleboy
Copy link
Member

@willemvd build fails

@willemvd
Copy link
Contributor Author

Build failure over a file I didn't change and cannot be found at that location? 😕
modules/helper.go -> golint failure but file does not exist

@appleboy
Copy link
Member

@willemvd Please rebase the latest version of master. See #1017

@willemvd
Copy link
Contributor Author

Not sure what happend , but rebase seems to have messed up my PR
See duplicate commits in my history 😕
Not sure what will happen when this gets merged... maybe create a new PR ?

@willemvd
Copy link
Contributor Author

@lunny @appleboy any idea ? (see my previous comment) & when I do a merge locally on master with this PR , history will be messed up with duplicate entries

@lunny
Copy link
Member

lunny commented Feb 23, 2017

git fetch origin
git rebase master
... resolve the conflict
git add <conflict file>
git rebase --continue
git push --force <your repo and branch>

@willemvd
Copy link
Contributor Author

Will that work even in this broken state?

@willemvd willemvd force-pushed the additional-oauth2-providers branch from acc2097 to 8b8b5f4 Compare February 23, 2017 08:44
@willemvd
Copy link
Contributor Author

@lunny created a new branch of upstream/master and cherry-picked the commits on top of it, after git push --force it seems to be ok now 😄

models/error.go Outdated
// / | \/ | \ | / | | \ Y /
// \_______ /\____|__ /______/ |____| \___|_ /
// \/ \/ \/

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe you could take the chance to start with splitting error.go into error_oauth.go ...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done , also moved some stuff from login_source.go to oauth2.go

_, err := x.Id(source.ID).AllCols().Update(source)
if err == nil && source.IsOAuth2() {
if err == nil && source.IsOAuth2() && source.IsActived {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Spelling: source.IsActive , this needs to be renamed.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is reuse of existing code, so I think out of scope for this PR

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not only that, it's also in a DB model so changing that field would require a migration :/

},
"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"},
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe add stack exchange as well?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Think this is not yet available in https://github.com/markbates/goth/#supported-providers or is it named differently?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for the record; stackexchange (also?) supports OpenID-2.0, and you can use openid.stackexchange.com to login (will be converted to actual URL upon logging in)

{{.i18n.Tr "admin.auths.tips"}}
</h4>
<div class="ui attached segment">
<h5>GMail Settings:</h5>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Gmail, not GMail. Maybe also add this to translations?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is reuse of existing code, so I think out of scope for this PR

<span>{{.i18n.Tr "admin.auths.tip.twitter"}}</span>
</div>
</div>
</div>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a way to make this automated (maybe a loop)?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will have a look if this can be a loop over the existing OAuth2 providers

@strk
Copy link
Member

strk commented Mar 20, 2017

It would also be nice to get #1300 merged before this. @geek1011 can you resolve conflicts there ?

# Conflicts:
#	routers/user/auth.go
#	templates/user/auth/signin_inner.tmpl
@lunny
Copy link
Member

lunny commented Apr 6, 2017

@willemvd is this ready to review?

@willemvd
Copy link
Contributor Author

willemvd commented Apr 6, 2017

@lunny yes it is, unfortunately the last push didn't triggered a drone build so maybe you can manually trigger this (or I could do a merge/rebase with master)

@lunny
Copy link
Member

lunny commented Apr 6, 2017

@willemvd please send a rebase, I cannot find the link to the drone build.

@willemvd
Copy link
Contributor Author

willemvd commented Apr 6, 2017

@lunny drone is almost done without failures, so it is ready! 😄

@lunny
Copy link
Member

lunny commented Apr 7, 2017

I have tested google+ and twitter, both are OK. but /user/link_account UI is broken. Otherwise LGTM

@tboerger tboerger added lgtm/need 1 This PR needs approval from one additional maintainer to be merged. and removed lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. labels Apr 7, 2017
@bkcsoft
Copy link
Member

bkcsoft commented Apr 19, 2017

Are we allowed to use these logos? Why not use the ones in FontAwesome?

(Edit: I know for a fact that GitLab is missing from FA...)

Copy link
Member

@bkcsoft bkcsoft left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

formatting

"code.gitea.io/gitea/modules/base"
"code.gitea.io/gitea/modules/context"
"code.gitea.io/gitea/modules/log"
"code.gitea.io/gitea/modules/setting"
"github.com/Unknwon/com"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Newline before external packages

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added

{{range $key, $value := .OAuth2Providers}}
<div class="item" data-value="{{$key}}">{{$value.DisplayName}}</div>
{{end}}
<!-- OAuth2 -->
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Weird indentation

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

@sapk
Copy link
Member

sapk commented Apr 28, 2017

Build seems to failed because the vendor github.com/mrjones/oauth doesn't correspond to remote. If you make change in the lib please revert them. A simple command to revert to original version is govendor fetch github.com/mrjones/oauth. This will also update the lib but, in this case, since it is not allready in repo there is no problems.

@willemvd
Copy link
Contributor Author

willemvd commented May 1, 2017

Didnt change anything to that lib so not sure why this happened, but I have updated the lib

@appleboy
Copy link
Member

appleboy commented May 1, 2017

LGTM

@tboerger tboerger added lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. and removed lgtm/need 1 This PR needs approval from one additional maintainer to be merged. labels May 1, 2017
@lunny lunny merged commit 950f2e2 into go-gitea:master May 1, 2017
@go-gitea go-gitea locked and limited conversation to collaborators Nov 23, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. type/feature Completely new functionality. Can only be merged if feature freeze is not active.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants