Skip to content

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

Merged
rangoDJ merged 2 commits into
mainfrom
fix/revoke-session-on-logout
Oct 10, 2026
Merged

rangoDJ merged 2 commits into
mainfrom
fix/revoke-session-on-logout

Conversation

@rangoDJ

@rangoDJ rangoDJ commented Oct 10, 2026

Copy link
Copy Markdown
Owner

Fixes #57

Replaces #62, which GitHub closed when its base branch (#61's) was deleted on merge. Same change, now merged with main.

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 (merged with main): all pass. 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

rangoDJ and others added 2 commits October 10, 2026 18:06
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 merged commit 2c3946a into main Oct 10, 2026
4 checks passed
@rangoDJ
rangoDJ deleted the fix/revoke-session-on-logout branch October 10, 2026 22:25
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.

Logging out doesn't end the session server-side

1 participant