Repository navigation
Synchronize account and user token lifetimes #2627
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
Changes from all commits
d5d1741
33490fd
8f45631
051996d
af8856d
77b3704
4504e74
d879f1b
a178e7b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -136,6 +136,9 @@ protected override async Task<AuthenticateResult> HandleAuthenticateAsync() | |
| return AuthenticateResult.Fail("Token is not valid"); | ||
| } | ||
|
|
||
| if (!user.HasValidAuthenticationVersion(tokenRecord.AuthenticationVersion)) | ||
| return AuthenticateResult.Fail("Token is not valid"); | ||
|
Comment on lines
+139
to
+140
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
When token cleanup fails and an authentication request began an uncached user read before a password change, that request can publish the old user snapshot to the cache after Useful? React with 👍 / 👎. |
||
|
|
||
| return AuthenticateResult.Success(CreateUserAuthenticationTicket(user, tokenRecord)); | ||
| } | ||
|
|
||
|
|
@@ -252,6 +255,9 @@ private async Task<AuthenticateResult> AuthenticateOAuthBearerAsync(string token | |
| return AuthenticateResult.Fail("User is not valid"); | ||
| } | ||
|
|
||
| if (!user.HasValidAuthenticationVersion(tokenRecord.AuthenticationVersion)) | ||
| return AuthenticateResult.Fail("User is not valid"); | ||
|
|
||
| var activeOAuthOrganizationIds = user.GetActiveOAuthOrganizationIds(tokenRecord); | ||
| if (activeOAuthOrganizationIds.Count == 0) | ||
| { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When token cleanup fails—the case this generation is intended to protect—an already-authenticated request can retain the pre-rotation
Userand later overwrite this property through an unrelated whole-document save. For example,OrganizationHandler.AddModelAsynccaptures the request user before awaiting organization creation and then callsSaveAsync(user); if a password change completes between those operations, that save restores the old/null generation and makes the surviving old tokens valid again. Persist the generation separately, use partial updates for unrelated user mutations, or enforce optimistic concurrency so stale user documents cannot undo revocation.AGENTS.md reference: AGENTS.md:L79-L82
Useful? React with 👍 / 👎.