D37 · A user's sessions end when their access changes
Accepted · 2026-10-14 · zuki · Partly superseded by D48 (which changes end sessions)
Decision: When a user's roles or overrides change, the database ends all of that user's sessions and records the time. proxy.ts refuses any login token issued before that time and sends the user to sign in again. The change takes effect on their next request.
Why: The higher-ups want an access change to log the user out at once (#144). v2 verifies the login token locally with the signing key (D13), and a token that has been issued stays valid until it expires, an hour by default. Ending the session stops a refresh but not a token already in hand, so the request itself has to check.
Consequences:
- Two parts, both in the database (D3): a trigger on the roles and overrides tables ends the user's sessions and stamps the profile; the function
session_is_current()says whether a token's issue time is after the stamp. - proxy.ts calls the function on every request and treats an error as "not current". It is one more read per request, next to the permissions read.
- Permissions are still never read from the token (R-ACC-08), so a refreshed token would be fine; ending the sessions is what forces the sign-in the higher-ups asked for.
- A change to your own roles signs you out too.
- R-ACC-08 is rewritten and a pgTAP test proves it on the local stack, with a Playwright check that the next request lands on /login. BE pack G1 (#150) and FE pack B2 (#151) build it.