Back-channel logout: end only the session named by sid #80

Merged
calvin merged 1 commit from oidc-session-sid into master 2026-11-14 22:30:09 +00:00
Owner

The provider's logout notice can arrive late (about 40 seconds on a real Authentik). A person who signs out and in again then lost the new session too, because Salt ended all their sessions. iat cannot be used as a cut-off: it is stamped when the notice is sent, not when the session ended.

  • Each single sign-on session keeps the ID token's sid (users_tokens.oidc_sid).
  • A notice with sid deletes that user's oidc_session rows with that sid OR with no sid (made before this change), and disconnects exactly those pages. Password sessions and other sids stay.
  • A notice with only sub deletes all of the user's sessions of both contexts, as before.
  • Unknown sid for a known user: 200; only that user's sid-less provider sessions end.
  • Log line says by=sid or by=sub and the count, never the sid.
  • verify_logout_token/1 now returns {:ok, %{sub, sid}}; a sid that is not a non-empty string counts as none (more sessions end, never fewer).

Migration 20261123090000: nullable column plus an index on (user_id, oidc_sid), no backfill, safe while the old code runs (it ignores the column). Old rows have nil and are treated as above.

Reissue: provider sessions are never reissued, and no path copies a token, so nothing needs to carry the sid.

Tests: the new database tests are :integration (CI); the verifier and token-builder tests run locally.

🤖 Generated with Claude Code

https://claude.ai/code/session_01DnYzaTxC2GmdSpvCNyHNne

The provider's logout notice can arrive late (about 40 seconds on a real Authentik). A person who signs out and in again then lost the new session too, because Salt ended all their sessions. `iat` cannot be used as a cut-off: it is stamped when the notice is sent, not when the session ended. - Each single sign-on session keeps the ID token's `sid` (`users_tokens.oidc_sid`). - A notice with `sid` deletes that user's `oidc_session` rows with that sid OR with no sid (made before this change), and disconnects exactly those pages. Password sessions and other sids stay. - A notice with only `sub` deletes all of the user's sessions of both contexts, as before. - Unknown sid for a known user: 200; only that user's sid-less provider sessions end. - Log line says `by=sid` or `by=sub` and the count, never the sid. - `verify_logout_token/1` now returns `{:ok, %{sub, sid}}`; a sid that is not a non-empty string counts as none (more sessions end, never fewer). Migration `20261123090000`: nullable column plus an index on `(user_id, oidc_sid)`, no backfill, safe while the old code runs (it ignores the column). Old rows have nil and are treated as above. Reissue: provider sessions are never reissued, and no path copies a token, so nothing needs to carry the sid. Tests: the new database tests are `:integration` (CI); the verifier and token-builder tests run locally. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01DnYzaTxC2GmdSpvCNyHNne
Back-channel logout: end only the session named by sid
All checks were successful
ci/woodpecker/pr/image Pipeline was successful
ci/woodpecker/pr/quality Pipeline was successful
ci/woodpecker/pr/integration Pipeline was successful
f72369015c
Keep the ID token's sid with each single sign-on session (users_tokens.oidc_sid,
nullable, no backfill). A notice with a sid ends that person's oidc_session
rows with that sid or with none, and disconnects only those pages. A notice
without one ends all the person's sessions as before.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DnYzaTxC2GmdSpvCNyHNne
calvin merged commit 5a448a9640 into master 2026-11-14 22:30:09 +00:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
external/salt-dns!80
No description provided.