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

Login via OpenID-2.0 #618

Merged
merged 16 commits into from
Mar 17, 2017
Merged

Login via OpenID-2.0 #618

merged 16 commits into from
Mar 17, 2017

Conversation

strk
Copy link
Member

@strk strk commented Jan 8, 2017

This branch superceeds the one in #271,
fixes #185 (once ready)

This version does not make "OpenID" a "Login Source"
but rather a first-class login method which is alternative
to the "username"/"password" pair.

The idea is to allow users to add their OpenID in the settings
and to allow registering via OpenID. Code is not yet complete.

@strk
Copy link
Member Author

strk commented Jan 8, 2017

@stevenroose if you want to take a look at the new approach that'll help.

@tboerger tboerger added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label Jan 8, 2017
models/user.go Outdated
@@ -86,6 +86,7 @@ type User struct {
Orgs []*User `xorm:"-"`
Repos []*Repository `xorm:"-"`
Location string
OpenID string `xorm:"UNIQUE"`
Copy link
Member

Choose a reason for hiding this comment

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

Then OpenID should be null default.

@@ -689,6 +690,7 @@ please consider changing to GITEA_CUSTOM`)
CookieRememberName = sec.Key("COOKIE_REMEMBER_NAME").MustString("gitea_incredible")
ReverseProxyAuthUser = sec.Key("REVERSE_PROXY_AUTHENTICATION_USER").MustString("X-WEBAUTH-USER")
MinPasswordLength = sec.Key("MIN_PASSWORD_LENGTH").MustInt(6)
EnableOpenIDLogin = sec.Key("ENABLE_OPENID_LOGIN").MustBool(true)
Copy link
Member

Choose a reason for hiding this comment

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

For compatible consideration, default should be false.

@lunny
Copy link
Member

lunny commented Jan 9, 2017

Why not implemented as a login type like SMTP or PAM?

@lunny lunny added this to the 1.1.0 milestone Jan 9, 2017
@lunny lunny added the type/feature Completely new functionality. Can only be merged if feature freeze is not active. label Jan 9, 2017
@bkcsoft bkcsoft added type/proposal The new feature has not been accepted yet but needs to be discussed first. pr/wip This PR is not ready for review type/feature Completely new functionality. Can only be merged if feature freeze is not active. and removed type/feature Completely new functionality. Can only be merged if feature freeze is not active. labels Jan 9, 2017
@bkcsoft
Copy link
Member

bkcsoft commented Jan 9, 2017

I'm also not very happy about introducing new "first-class login-methods", should IMO be implemented like PAM/SMTP/LDAP. Unless you have a really good reason not to 😉

@strk
Copy link
Member Author

strk commented Jan 9, 2017 via email

@strk
Copy link
Member Author

strk commented Jan 9, 2017 via email

@strk
Copy link
Member Author

strk commented Jan 9, 2017 via email

@strk
Copy link
Member Author

strk commented Jan 9, 2017 via email

@strk
Copy link
Member Author

strk commented Jan 9, 2017 via email

@bkcsoft
Copy link
Member

bkcsoft commented Jan 9, 2017

How do I specify that I want a null default ? That's what I want.

xorm:"UNIQUE default null"

@strk
Copy link
Member Author

strk commented Jan 9, 2017 via email

@bkcsoft
Copy link
Member

bkcsoft commented Jan 9, 2017

I've just checked and at least on PostgreSQL those field already have a default of null. Is that not the case for other backends ?

Better to be specific than to depend on current behaviour :)

@strk
Copy link
Member Author

strk commented Jan 9, 2017

TODO:

  • Check for OpenID validity before setting it in user settings

  • Add "Remember me" support upon login

  • Allow registering or connecting existing user signing in with valid but unknown OpenID

  • Do not leak nonce and discovery caches

  • Let admin specify whitelist/blacklist patterns for accepted/denied OpenID uris

  • Add support for OpenID 1 (wordpress.com - wordpress.com OpenID provider not supported yohcop/openid-go#43)

@strk
Copy link
Member Author

strk commented Jan 10, 2017

For the record: openid.stackexchange.com works as a provider with this implementation

@strk
Copy link
Member Author

strk commented Jan 13, 2017

For the record I've just tested this implementation against GNUSocial OpenID provider and it does work great :)

@couling
Copy link
Contributor

couling commented Jan 15, 2017

Another thing: when you successfully authenticate via OpenID but no local user with such OpenID is known, the OpenID Login should prompt you to register as a new user OR "connect" your OpenID to an existing account, providing username/password to confirm it belongs to you. Once again this mechanism is very far from the PAM/SMTP/LDAP auth methods.

I'm less familiar with OpenID's internals. Does it provide an authenticated email address?

One thing I've seen when authenticating with my google account is that it acts as an alternative auth mechanism... IE once or twice I forgot that I'd originally signed up on a website with a username & password and later just clicked the "login with google" button. The result was that it logged me in without question (or asking my password).

Likewise many sites provide a streamlined account creation (skipping the email verification step) as google verifies the email.

@lunny lunny modified the milestones: 1.2.0, 1.1.0 Jan 15, 2017
@strk
Copy link
Member Author

strk commented Jan 16, 2017 via email

@lunny
Copy link
Member

lunny commented Mar 17, 2017

Is the OpenID login could be disabled?

@pgaskin
Copy link
Contributor

pgaskin commented Mar 17, 2017 via email

@bkcsoft
Copy link
Member

bkcsoft commented Mar 17, 2017

Yeah it's good enought for now. We could iterate on it later if it becomes a pain 🙂

@pgaskin
Copy link
Contributor

pgaskin commented Mar 17, 2017

I am not sure if it is this PR or not, but I think this PR may be causing issues with GitHub OAuth2.

@bkcsoft bkcsoft merged commit 71d16f6 into go-gitea:master Mar 17, 2017
@strk
Copy link
Member Author

strk commented Mar 17, 2017 via email

@Quix0r
Copy link

Quix0r commented Mar 21, 2017

Just a side question: If I rebase my work, the PR relinks all commits and the code-reviewers have to work all over again. How can I prevent this from happening? Tons of merges (as I have to keep it in-sync with development branch) is surely working but not always wanted as it causes a complex GIT history.

And thank you @strk for your work. 👍

@Quix0r
Copy link

Quix0r commented Mar 21, 2017

Is this installed at https://staging.geek1011.net/ ? Because when I try to login with my OpenID at https://social.mxchange.org/roland, I noticed two things:

  1. redirection happens over http:// and not entirely https://
  2. login is not given (not signup tried before)

cookies and JavaScript are allowed.

@strk
Copy link
Member Author

strk commented Mar 22, 2017

This branch is actually merged to master now, and functionality is exposed on try.gitea.io

@strk
Copy link
Member Author

strk commented Mar 22, 2017

@Quix0r please file a ticket if things don't work for you.
NOTE: I tried your OpenID url and was redirected for login to https://social.mxchange.org/main/login (so https)

@strk
Copy link
Member Author

strk commented Mar 22, 2017

BTW: you might be interested in some OpenID merge requests I filed for GNUSocial, as I see your instance is also affected. Take a look at these:
https://git.gnu.io/gnu/gnu-social/merge_requests/139
https://git.gnu.io/gnu/gnu-social/merge_requests/138
https://git.gnu.io/gnu/gnu-social/issues/60 (fixed by merging openid/php-openid#134)

@Quix0r
Copy link

Quix0r commented Mar 23, 2017

Okay, seems to work here: https://try.gitea.io/Quix0r So I guess it is not my instance (it is now pure GS code, without my changes).

@danielfbm
Copy link

Hi, just to raise a question in a related issue before creating a new one. Are there any plans to support OpenID Connect as well, or are we staying with OpenID 2.0?
Thanks in advance

@Quix0r
Copy link

Quix0r commented Dec 29, 2017

Not working anymore: Application Version: 08cf7d9 will give a 500 error with enabled cookies and local storage (maybe not needed?)

@strk
Copy link
Member Author

strk commented Dec 30, 2017 via email

@danielfbm
Copy link

danielfbm commented Dec 31, 2017

@strk I found it in Admin Console > Authentication > oAuth2 > OpenID Connect.

I tested with dex and it is working. Thanks

@strk
Copy link
Member Author

strk commented Dec 31, 2017

ah, great, thanks for testing!

@strk
Copy link
Member Author

strk commented Dec 31, 2017

Correct dex link, for the record: https://github.com/coreos/dex

@sbrl
Copy link

sbrl commented Dec 31, 2017

Umm that link to dex takes me to a gitea comparison, @danielfbm

@danielfbm
Copy link

@sbrl sorry, already updated the link

@micheelengronne
Copy link

Is it possible to force OpenID auth and to a certain provider ?

My usecase is as follow:

I would like to integrate Gitea in a more global solution containing other tools. I would like users to be able to connect through the OIDC server of this solution and going to gitea seamlessly.

So, I would like a way to redirect the Gitea login page to this specific OIDC server only in order to connect and use the complete sets of OIDC RFCs to manage sessions, user logout (frontend and backend), user lifecycle (insert, update, delete, frontend and backend).

Thanks.

@lafriks
Copy link
Member

lafriks commented Apr 8, 2020

Please do not comment on old merged PR. For feature requests open new issues for questions please use our discord channel or gitea forum https://discourse.gitea.io/

@go-gitea go-gitea locked as resolved and limited conversation to collaborators Apr 8, 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.

Support federated login for guest users (OpenID)