Sessions from single sign-on end after a set time; command to end a person's sessions #78
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "oidc-session-limit"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
A person disabled at the identity provider kept a valid Salt session for up to 14 days. This limits sessions that came from single sign-on and adds an operator command to end one person's sessions.
What changes
SALT_DNS_OIDC_SESSION_HOURS(default 12, whole number 1 to 336). A session that began with single sign-on is valid for that many hours. After that the next request is signed out and the normal sign-in follows. An invalid value stops the boot with a clear message (same check as the neighbouring settings). Password sessions keep 14 days.Accounts.delete_all_user_session_tokens/1deletes every session token of a user (password and single sign-on), disconnects their open pages, and returns how many tokens it removed.SaltDns.Release.sign_out_user(email)for operators. Prints the count. An unknown address prints a clear message and changes nothing (returns{:error, :not_found}, no crash). Documented indocs/operations.md, "Ending a person's sessions".docs/configuration.md(new row),docs/operations.md(session life and the provider case; there is no security page, so it sits next to the command), CHANGELOG.Design: how single sign-on sessions are marked
A distinct token context,
oidc_session, next to the existingsession. Chosen over a nullable column because it needs no migration and no backfill, the verify query stays one indexed lookup, and the two lives are visibly separate rows. Existing code that deletes tokens by user (password change, magic link) already deletes every context. The OIDC callback passesmethod: :oidcthroughUserAuth.log_in_user/4togenerate_user_session_token/2.Reissue:
UserAuthmakes a fresh token for a session older than 7 days. A new "session" token would have restarted the clock and defeated the limit (reachable when the setting is above 168 hours). Single sign-on sessions are therefore never reissued; the person signs in again at the limit.Sockets that are already connected
Not enforced, and I did not build anything for it.
on_mountchecks the token once, at mount. There is no periodic check in the shared hooks (the existing timers are per-page refreshes), and a socket only re-checks when it reconnects or the page is loaded again. So an open page can outlive the limit until then. Reaching it cleanly would need a timer in every LiveView or a hook withattach_hookplusProcess.send_afterin every live_session. I judged that elaborate and left it for the maintainers to decide.Related:
sign_out_userruns in a separate Erlang VM underbin/salt_dns eval, where the application's PubSub is not running, so it cannot disconnect open pages. It deletes the tokens; open pages end at their next load or reconnect, and restarting the application cuts them at once. This is stated in the docs and the function doc. Inside the running application (tests, any in-app caller) the pages are disconnected.Migration and existing tokens
No migration. After deploy, tokens already in
users_tokenshave contextsessionand keep the 14 days they were given, including sessions that came from single sign-on before the upgrade. Only new single sign-on sign-ins get the short life. To remove an existing person now, runsign_out_userfor them. It is safe on a running system: it only deletes rows.Tests
Accounts (OIDC token accepted at 11 hours and refused at 13, by moving
inserted_at; password token unaffected at 13 hours and refused at 15 days; delete all returns the count, disconnects and keeps other users and non-session tokens), release task (known and unknown address), runtime config validation (valid 1, 12, 336; invalid 0, 337, -1, 12h, text), andUserAuth(OIDC login makes anoidc_sessiontoken that is refused after the limit; password session unaffected). TheUserAuthtests are tagged:integration, so CI runs them; they did not run locally.Not merged. Not deployed.
🤖 Generated with Claude Code
https://claude.ai/code/session_01DnYzaTxC2GmdSpvCNyHNne