Skip to content

fix(session): Keep remembered logins across the session timeout - #65959

Open
DerDreschner wants to merge 1 commit into
masterfrom
fix/session-timeout-issues
Open

DerDreschner wants to merge 1 commit into
masterfrom
fix/session-timeout-issues

Conversation

@DerDreschner

@DerDreschner DerDreschner commented Oct 27, 2026 •

Copy link
Copy Markdown
Member

Summary

The "Remember me" feature doesn't work correctly under some circumstances. One of them is that a session that was idle for longer than session_lifetime is ended with a full logout, which also deletes the cookies necessary for the "Remember me" feature. This contradicts the documentation for session_lifetime, which states that users with "Remember me" may be transparently re-authenticated after the session expired, as long as the "Remember me" cookie remains valid:

* When "Remember me" is enabled, users may be transparently
* re-authenticated after session expiry/logout while the remember-login
* cookie remains valid.

This is changed with this PR. If the request carries "Remember me" cookies, only the session data is cleared and the cookies are kept, so the normal "Remember me" login signs the user in again with a new token, as it does whenever the session is gone. This needs no database, so it also works in maintenance mode or with a pending upgrade.

Checklist

AI (if applicable)

  • The content of this PR was partly or fully generated using AI

@DerDreschner DerDreschner self-assigned this Oct 27, 2026
@DerDreschner
DerDreschner requested a review from a team as a code owner October 27, 2026 09:48
@DerDreschner DerDreschner added bug 3. to review Waiting for reviews labels Oct 27, 2026
@DerDreschner
DerDreschner requested review from Altahrim, provokateurin and sorbaugh and removed request for a team October 27, 2026 09:48
@DerDreschner
DerDreschner requested a review from come-nc October 27, 2026 09:48
@DerDreschner
DerDreschner force-pushed the fix/session-timeout-issues branch 2 times, most recently from 4b3ea84 to d808057 Compare October 27, 2026 10:15
@DerDreschner
DerDreschner enabled stacked auto-merge October 27, 2026 10:48
@DerDreschner
DerDreschner force-pushed the fix/session-timeout-issues branch 4 times, most recently from 3b69c65 to 6a8713f Compare October 28, 2026 09:19
@DerDreschner
DerDreschner force-pushed the fix/session-timeout-issues branch from 6a8713f to b58a3cc Compare November 5, 2026 18:17
@DerDreschner
DerDreschner requested a review from a team as a code owner November 5, 2026 18:17
@DerDreschner
DerDreschner marked this pull request as draft November 5, 2026 18:53
stacked auto-merge was automatically disabled November 5, 2026 18:53

Pull request was converted to draft

@DerDreschner
DerDreschner force-pushed the fix/session-timeout-issues branch from b58a3cc to 7ee6061 Compare November 6, 2026 08:43
@DerDreschner
DerDreschner marked this pull request as ready for review November 6, 2026 08:44
@DerDreschner
DerDreschner enabled stacked auto-merge November 6, 2026 08:44
@DerDreschner DerDreschner added this to the Nextcloud 36 milestone Nov 6, 2026
@DerDreschner

Copy link
Copy Markdown
Member Author

/backport to stable35

@DerDreschner

Copy link
Copy Markdown
Member Author

/backport to stable34

@DerDreschner

Copy link
Copy Markdown
Member Author

/backport to stable33

@DerDreschner DerDreschner removed this from the Nextcloud 36 milestone Nov 6, 2026
@DerDreschner
DerDreschner force-pushed the fix/session-timeout-issues branch from 7ee6061 to 626eed5 Compare November 6, 2026 10:17
@pringelmann

Copy link
Copy Markdown
Contributor

Non-blocking question: could endInactiveSession() just clear the session and keep the remember-me cookies, like the maintenance branch does? Then the normal remember-me login would handle the rest and you'd get a new token as usual. Or is there a case where that doesn't work?

@DerDreschner
DerDreschner disabled stacked auto-merge November 6, 2026 10:50
@DerDreschner

Copy link
Copy Markdown
Member Author

@pringelmann: Yeah, that works and is a good idea. I'll change it.

A session that was idle for longer than session_lifetime is ended with a
full logout, which also deletes the remember-me cookies. The user is logged
out for good, although they asked to stay logged in and the documentation
of session_lifetime says a remembered login is transparently
re-authenticated after the session expired.

When the request carries remember-me cookies, endInactiveSession() now only
drops the session data and keeps the cookies. The remember-me login then
signs the user in again and replaces the remember-me token, as it does
whenever the session is gone. Any other session is still ended with a
logout. As this needs no database, it also applies in maintenance mode and
with a pending upgrade, and the login continues once the instance is
available again.

The remember-me login is now only attempted with cookies that are strings,
and loginWithCookie() requires strings. Unlocking a password-protected
share only re-issues remember-me cookies that are strings. Clients can send
the cookies as arrays, which ended in a TypeError.

Assisted-by: ClaudeCode:claude-opus-5
Assisted-by: ClaudeCode:claude-opus-5-5
Signed-off-by: David Dreschner <david.dreschner@nextcloud.com>
@DerDreschner

Copy link
Copy Markdown
Member Author

@pringelmann Done! The second part is available as draft in #66416 now as well.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants