-
-
Notifications
You must be signed in to change notification settings - Fork 5.7k
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
OAuth2 registered accounts should still be local #1124
Comments
@strk I agree that the current behavior seems a bit weird and inconsistent. However I don't think I understand the overall login code well enough to have an opinion on what the "correct" implementation should be. In general I definitely agree with this, though:
|
I think the current rationale for a LoginSource to even exist
in the User table is because when you login with username/password
the code checks if the user (by username) is known and if it
is delegates password checking to the asociated LoginSource.
Code is in models/login_source.go within the UserSignIn function.
You can see how the inconsistency of OAuth2 can also be seen there,
around here:
```
switch user.LoginType {
case LoginNoType, LoginPlain, LoginOAuth2:
if user.ValidatePassword(password) {
return user, nil
}
```
... doesn't make sense to me to call user.ValiatePassword for a user
with LoginOAuth2 source, does it ?
|
@morrildl, @willemvd please see how you like the solution in #1143. |
I agree that we have two different external login source. One is auth login source that means where we check user's password LOCAL/LDAP/SMTP/PAM should this kind. Another is link accounts, an user (include LOCAL/LDAP/SMTP/PAM user) could link to other accounts (github/google and etc.), the link type could be OAuth/OAuth2/OpenID and etc. We really need a clear document to record this. |
Never set OAuth in User.LoginSource, which keeps referring to the username/password interpretation. Fixes go-gitea#1124
This issue 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 weeks. Thank you for your contributions. |
This issue has been automatically closed because of inactivity. You can re-open it if needed. |
Never set OAuth in User.LoginSource, which keeps referring to the username/password interpretation. Fixes go-gitea#1124
@wxiaoguang summoned me with #1143 (comment). 🧙 |
Still exists in the current main branch. (That's a really old one) Several drawbacks:
The expected behavior should be discussed and documented. |
We can have a whole design first and then migrate step by step. Maybe a user should always have a record in the After all of these changes, how to process the user login? When login with the username and password, previously we will try with his login type, we can search first for the password on |
Isn't this basically the problem PAM solves at the system level? See how they do it. |
Looks like this has been open for a while, but to add my two cents, this creates a problem when you set up the system so that the admin has to create user accounts. If I create an account using an OAuth2 authentication source and send an email to the newly created user:
|
I think this is important to fix before 1.1.0 final.
The current code handling OAuth2 users registration encodes the OAuth2 LoginSource in the user table, while still assigning a username/password pair to the newly create user that is supposed to be usable for "local" authentication. This is an inconsistent way to use that LoginSource field because then you would not know what username/password refer to unless by adding special code to handle "OAuth2" source. Indeed this is the special code added, for example in ForgotPasswordPost:
That's weird, because the OAuth2 user's password is indeed a "local" password,
so why should there be a difference ? The code also added an IsOauth2 method to the User table, building on what seems to be a broken model.
Users should not BE local or Oauth2, credentials should be. Users can be recognized by multiple credentials, but we'd always know about them locally, so they are all local.
The inconsistency is confirmed by the fact that you can still associate an OAuth2 credential to your previosuly-registered account resulting in a "IsLocal" user with exactly the same caracteristic of the "IsOAuth2" user, except the "LoginSource" is different. Characteristics being: you can login with local username/password as well as with "OAuth2" credentials.
My suggestion here is to always keep the "LoginSource" field as an indication of the semantic for the "LoginSource" and "Password" fields in the "User" table, so to never use an OAuth2 LoginSource identifier in that table.
Can you see any drawback in that ?
\cc @willemvd
The text was updated successfully, but these errors were encountered: