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

Always put OAuth user info in the ExternalLoginUser table #1143

Closed
wants to merge 3 commits into from

Conversation

strk
Copy link
Member

@strk strk commented Mar 7, 2017

Never set OAuth in User.LoginSource, which keeps referring to
the username/password interpretation. Fixes #1124

\cc @willemvd, @morrildl, @lunny, @bkcsoft

I think this should be done before 1.1.0

@lunny
Copy link
Member

lunny commented Mar 8, 2017

It's really to need a proposal document to describe all the login.

@tboerger tboerger added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label Mar 8, 2017
@lunny lunny added this to the 1.2.0 milestone Mar 8, 2017
@lunny lunny added the type/refactoring Existing code has been cleaned up. There should be no new functionality. label Mar 8, 2017
@strk
Copy link
Member Author

strk commented Mar 8, 2017 via email

@strk
Copy link
Member Author

strk commented Mar 8, 2017

Note that doing this after 1.1.0 is out will require a new migration to convert existing records with OAuth2 in User.LoginSource

@pgaskin
Copy link
Contributor

pgaskin commented Mar 8, 2017

@strk but even if it is done before, what happens to the installs from master builds (such as my own)?

@strk
Copy link
Member Author

strk commented Mar 9, 2017

@geek1011 good question, I guess those would be just left with inconsistent database values. You might end up having users with OAuth2 LoginSource and no way to login with those OAuth2.

u := &models.User{
Name: form.UserName,
Email: form.Email,
Passwd: form.Password,
IsActive: !setting.Service.RegisterEmailConfirm,
LoginType: models.LoginOAuth2,
Copy link
Member

Choose a reason for hiding this comment

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

LoginType should be plain?

Copy link
Member Author

Choose a reason for hiding this comment

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

The default is LoginNone, which is threated by code the same as LoginPlain.
But yes, I guess it could be LoginPlain as long as we guarantee the actual login is not of the LDAP or SMTP or PAM type...

@@ -648,6 +625,13 @@ func LinkAccountPostRegister(ctx *context.Context, cpt *captcha.Captcha, form au
}
log.Trace("Account created: %s", u.Name)

// Link the oAuth account to the user
err := models.LinkAccountToUser(u, gothUser.(goth.User))
Copy link
Member

Choose a reason for hiding this comment

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

How to migrate the old user?

Copy link
Member Author

Choose a reason for hiding this comment

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

Now that 1.1.0 is out yes, this is a problem. Too bad you didn't want to merge this before (we saw people had problems with early upgrades anyway, so this would have not been different)

Copy link
Member

Choose a reason for hiding this comment

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

Just like @geek1011 said, there many people use master, a migration needed.

@lunny
Copy link
Member

lunny commented Mar 11, 2017

I like this idea. There are two kinds of external Login Source. One is provide password authentication, another is for link.

@strk
Copy link
Member Author

strk commented Mar 11, 2017 via email

@lunny
Copy link
Member

lunny commented Mar 11, 2017

@strk, when you review a PR, if you think your opinion should not be ignored, you could use github's request changes, then the merger should ask your confirmation before merge it. Our rules only consider two reviewers, lost this rule.

@lunny
Copy link
Member

lunny commented Mar 11, 2017

I will try to add migration for this PR when I have time.

@bkcsoft
Copy link
Member

bkcsoft commented Nov 1, 2017

@lunny Did you have time to work on this? Otherwise I suggest we close this as "out of date"

@lunny
Copy link
Member

lunny commented Nov 2, 2017

@bkcsoft I'm afraid I have no time to work on this. I still have serval PRs in v1.3 and v1.4 need work.

@lafriks lafriks modified the milestones: 1.3.0, 1.4.0 Nov 2, 2017
@lafriks lafriks modified the milestones: 1.4.0, 1.5.0 Jan 14, 2018
@techknowlogick techknowlogick modified the milestones: 1.5.0, 1.6.0 May 25, 2018
@techknowlogick techknowlogick removed this from the 1.6.0 milestone Aug 28, 2018
@strk strk force-pushed the local-source-oauth-users branch from a7d5065 to b82fd19 Compare June 3, 2019 07:31
@stale
Copy link

stale bot commented Aug 2, 2019

This pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs during the next 2 months. Thank you for your contributions.

@stale stale bot added the issue/stale label Aug 2, 2019
@lunny lunny added the issue/confirmed Issue has been reviewed and confirmed to be present or accepted to be implemented label Aug 3, 2019
@stale stale bot removed the issue/stale label Aug 3, 2019
@strk
Copy link
Member Author

strk commented Aug 6, 2019

Still relevant, not sure why Travis is sad

@lafriks
Copy link
Member

lafriks commented Aug 6, 2019

As per integration tests there is error in template:

template: user/settings/account:10:45: executing "user/settings/account" at <.SignedUser.IsOAuth2>: can't evaluate field IsOAuth2 in type interface {}

Never set OAuth in User.LoginSource, which keeps referring to
the username/password interpretation. Fixes go-gitea#1124
@singuliere
Copy link
Contributor

Refactors moved routers/auth.go to routers/user/auth.go and the IsOAuth2 method from models/user.go to models/user/user.go but the logic changed by this PR remains the same. @strk it looks like your initial motivation for creating this PR is still valid, right?

@singuliere singuliere self-requested a review January 2, 2022 21:40
@strk
Copy link
Member Author

strk commented Jan 2, 2022

Yes, the motivation remains valid. Unfortunately the high version of Go required to build Gitea made me in a position to have more problems contributing (can't build w/out installing a foreign package in my otherwise all-distro-based system, and I'm short on disk space). For this reason I can't test my change much. Will gladly accept a PR to my branch if you want to work on the refactoring porting.

@wxiaoguang
Copy link
Contributor

It's stale for petty long time.

What's the root problem behind the issue/PR?

Is there any valuable information in this context?

@wxiaoguang wxiaoguang added issue/needs-feedback For bugs, we need more details. For features, the feature must be described in more detail and removed issue/confirmed Issue has been reviewed and confirmed to be present or accepted to be implemented labels May 10, 2023
@strk
Copy link
Member Author

strk commented May 10, 2023

It was mostly a design concern, a way to separate "external" authentication sources from "internal" ones. One problem being resolved would be described in #1124 (comment) but that issue was closed by stale bot too

@wxiaoguang
Copy link
Contributor

Could some maintainers help to re-open that issue? @techknowlogick @lunny

@wxiaoguang
Copy link
Contributor

I think this PR/issue could be kept open, until there is a clear conclusion

@wxiaoguang wxiaoguang reopened this May 24, 2023
@pull-request-size pull-request-size bot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label May 24, 2023
@lunny
Copy link
Member

lunny commented Aug 22, 2023

#1124 was opened so I think we could close this one because it's outdated.

@denyskon
Copy link
Member

I also think we can close this and keep the issue open for further discussion

@lunny lunny closed this Sep 11, 2023
@go-gitea go-gitea locked as resolved and limited conversation to collaborators Dec 10, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
issue/needs-feedback For bugs, we need more details. For features, the feature must be described in more detail lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. type/refactoring Existing code has been cleaned up. There should be no new functionality.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

OAuth2 registered accounts should still be local