Repository navigation
fix(auth): Keep remember-me logins working for concurrent requests - #66416
Open
DerDreschner wants to merge 3 commits into
Open
DerDreschner wants to merge 3 commits into
DerDreschner wants to merge 3 commits into
Conversation
DerDreschner
force-pushed
the
fix/remember-me-token-rotation-grace
branch
from
November 6, 2026 18:35
bf2c8e6 to
abee5b7
Compare
5 of 7 tasks
DerDreschner
force-pushed
the
fix/remember-me-token-rotation-grace
branch
from
November 6, 2026 21:46
abee5b7 to
209bf79
Compare
3 of 7 tasks
A request can move its session twice: a remember-me login moves it, and unlocking a password-protected share in the same request moves it again. The second move looked at the cookies the request came with, which no longer point at the session it moves from. It did not re-issue the remember-me cookies, so nc_session_id kept pointing at a session token that is gone, and the next remember-me login failed. The user session now keeps track of the remember-me cookies it set or removed during the request and checks those instead of the ones the request came with. The remember-me login and the end of an inactive session read the cookies the same way, instead of from $_COOKIE and the request. Assisted-by: ClaudeCode:claude-opus-5-5 Signed-off-by: David Dreschner <david.dreschner@nextcloud.com>
A browser login renews its session token on every remember-me login. Each renewal stored a new token with a new id, so the entry in Devices & sessions changed its id while the browser was in use, and concurrent renewals of the same token forked the login into several session tokens that showed up as separate devices. Session tokens now know the login they belong to. Renewing a session token keeps it in the new login_id column, which points at the first token of the login. Devices & sessions shows one entry per login, and its id stays the same while the browser renews its session token. Revoking, wiping, renaming and logging out act on every token of the login, and so do occ user:auth-tokens:delete and deleting a user. "Revoke all other sessions" also ends the other session tokens of the current login, so only the session it is used from stays. App passwords and other tokens are logins of their own. Renewing a session token now locks and deletes it first, so only one request can renew it, and the new token takes the current name, scope and password of the old one. Changing a login locks its tokens, so a renewal stored while the login is renamed, restricted, revoked or wiped gets the same change. When unlocking a password-protected share loses that race to a concurrent request, its new session no longer stays logged in without a session token, which ended the remember-me login on the next request. It is logged out instead, so the remember-me cookies can log it in again. Assisted-by: ClaudeCode:claude-opus-5-5 Signed-off-by: David Dreschner <david.dreschner@nextcloud.com>
A remember-me login replaces the remember-me token and the session token on every use. Requests that were sent before the replacing response arrived, for example when a browser opens several tabs after its session is gone, still carry the replaced cookies. Their remember-me login failed, and they were logged out or shown the login page although their cookies were valid when they were sent. The replaced remember-me token and the replaced session token now stay valid for 60 seconds instead of being deleted. A request with the replaced cookies runs the normal remember-me login during that time and gets a session token of its own in the same login. The replaced session token keeps the time it was replaced in the new superseded_at column. It is refused once its grace period is over, and the daily token cleanup deletes it. Every renewal during the grace period writes the replaced session token, so database clusters that don't share row locks still see a concurrent revocation as a conflict. The stored time of the replaced remember-me token is moved back so that its lifetime ends with the grace period, and the remember-me login now refuses tokens older than remember_login_cookie_lifetime instead of relying on the cleanup job. Moving the session token when unlocking a password-protected share still deletes the old one at once. Assisted-by: ClaudeCode:claude-opus-5-5 Signed-off-by: David Dreschner <david.dreschner@nextcloud.com>
DerDreschner
force-pushed
the
fix/remember-me-token-rotation-grace
branch
from
November 18, 2026 14:34
209bf79 to
086e1b9
Compare
DerDreschner
marked this pull request as ready for review
November 18, 2026 14:35
DerDreschner
requested review from
a team,
ChristophWurst and
miaulalala
as code owners
November 18, 2026 14:35
DerDreschner
requested review from
Altahrim,
CarlSchwan,
come-nc,
marcoambrosini and
pringelmann
and removed request for
a team
November 18, 2026 14:35
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
A remember-me login replaces the remember-me token and the session token on every use. When several requests arrive with the same cookies after the session is gone, for example from a browser restoring its tabs, only the first one gets in and the others are logged out.
oc_authtoken.superseded_at).login_id. Devices & sessions shows one entry per login, and revoking or wiping it ends all of them.The migration needs a version bump, which is not part of this PR.
Checklist
3. to review, feature component)stable32)AI (if applicable)