Skip to content

End the session on the server when logging out - #62

Closed
rangoDJ wants to merge 1 commit into
fix/logout-post-onlyfrom
fix/revoke-session-on-logout
Closed

rangoDJ wants to merge 1 commit into
fix/logout-post-onlyfrom
fix/revoke-session-on-logout

Conversation

@rangoDJ

@rangoDJ rangoDJ commented Oct 10, 2026

Copy link
Copy Markdown
Owner

Fixes #57

Depends on #61 (POST-only logout) and is based on its branch: merge #61 first, then this PR's base switches to main automatically.

What changed

  • auth.py: a small session store in /config/sessions.json ({session id: expiry}, written atomically, mode 600, expired entries pruned on each login). create_session_cookie() puts a fresh sid in every cookie; get_current_user() also requires that sid to be active.
  • logout() revokes the cookie's session (end_session()) before clearing the cookie, so a copy of the cookie stops working too. Other sessions (other devices) are unaffected.
  • Applies to basic and OIDC logins (forward auth and AUTH_MODE=none have no ConnectHub session).
  • README: a "Sessions" note.

Upgrade note: cookies issued before this change carry no session id, so everyone has to sign in once after updating.

Testing

  • pytest: 255 passed, 8 skipped. New tests: a copied cookie is rejected after logout; logging out one session keeps another; sessions survive a restart (modules reloaded); a validly signed cookie without an active session is rejected; expired sessions are dropped from the file; a damaged sessions file means no sessions. Four fail without the fix.
  • Not tested in a running container.

🤖 Generated with Claude Code

Session cookies were self-contained signed tokens valid for 7 days, so
logging out only deleted the browser's copy: any other copy kept working,
and OIDC sessions could not be revoked at all. Each cookie now names a
session id that must be listed in /config/sessions.json; logout removes
it. Cookies issued before this change carry no id, so everyone signs in
once more after upgrading.

Fixes #57

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@rangoDJ
rangoDJ deleted the branch fix/logout-post-only October 10, 2026 22:21
@rangoDJ rangoDJ closed this Oct 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant