-
-
Notifications
You must be signed in to change notification settings - Fork 6.2k
Fix oauth2 sync error #35875
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
base: main
Are you sure you want to change the base?
Fix oauth2 sync error #35875
Conversation
We'd better to use id to find a user. Not LoginName. And LoginName!= ExternalID
It seems to be a log-only problem. It shouldn't output the user.ID into log because it is not used or set.
I don't think it is necessary. In Gitea: User.LoginName = ExternalLoginUser.ExternalID = OAuth2 Provider's UserID ( If you think here it is wrong, then there must be more places which are also wrong. |
|
Hi @wxiaoguang it is not a log-only problem. Let me show you what I got from our db: You can find the user 'Okta Support'(User ID is 19), his external_id is "00u1wwyot5yExxxxxd8", but his login_name is "okta". So, I think the LoginName!= ExternalID.
Actually, you can reproduce this issue as your wish. Just create a local account, and link it to oauth2 authn source. Finally, In Gitea: User.ID = ExternalLoginUser.UserID, this is what I have confirmed! |
Then there must be more wrong places in code which need to be fixed. Why and how AFAIK, User.LoginName = ExternalLoginUser.ExternalID, they should all use the OAuth2 Provider's Code screenshot: |
|
Hi @wxiaoguang
While I am not a Gitea expert, maybe other people can provide other PRs for this. |
Usually I don't approve an unclear change. If it is really unclear and unable to figure out, it needs enough comments and tests to document the problem.
So as the comment above #35875 (comment): cc @bohde @6543 @kdumontnu |
|
BTW, my gitea version is 1.24.3. And I have found another issue about 'expires_at' for FindExternalUserOptions in external_login_user.go The SQL query log show me that the expires_at in cond used UTC as timezone, but we have set CST in DB. There is timezone mismatch caused the oauth2 sync will delay 8 hours. This is our DB query log: '2025-11-05 10:46:02.181994211' is UTC, and the Expired is always "false". PS. I don't know how to fix it. So I just provide the details of the issue here. Or I can submit a new issue about this. |



We identified an issue with OAuth2 synchronization. The following logs indicate the problem:
The logs show that the gitea correctly identified the user with external ID 00u1wwyot5yExxxxxd8 for deactivation. However, the action was incorrectly applied to user ID 0 instead.
So, we'd better to use ID to identify a user, not LoginName. For Okta, the ExternalID is Okta User ObjectID, LoginName!= ExternalID.
#31572