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

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 valid "Remember me" cookies for the current session, only the session data is cleared, so the "Remember me" login signs the user in again.

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 force-pushed the fix/session-timeout-issues branch 2 times, most recently from 904df32 to d9f5052 Compare October 27, 2026 14:35
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.

End such a session with endInactiveSession() instead: when the request
carries valid remember-me cookies for the current session, only the
session data is dropped, so the remember-me login signs the user in again.
The cookies must belong to the user of the session token. No user backend
is set up yet when a session times out, so the session token tells whose
session it is. Any other request keeps being logged out as before.

The remember-me login is now only attempted with cookies that are strings,
and loginWithCookie() requires strings. Clients can send the cookies as
arrays, which ended in a TypeError for nc_username and nc_session_id.

Assisted-by: ClaudeCode:claude-opus-5
Assisted-by: ClaudeCode:claude-opus-5-5
Signed-off-by: David Dreschner <david.dreschner@nextcloud.com>
@DerDreschner
DerDreschner force-pushed the fix/session-timeout-issues branch from d9f5052 to 3b69c65 Compare October 27, 2026 14:37

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant