Sessions: JWT in httpOnly cookies, reworked from core-project #350
Labels
No labels
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
spec
wayfinder:grilling
wayfinder:map
wayfinder:prototype
wayfinder:research
wayfinder:task
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Blocks
#351 How does an account relate to the Seat token?
amaurycoudr/chess-project
#352 How are guest games merged into an account?
amaurycoudr/chess-project
Reference
amaurycoudr/chess-project#350
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
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?
Parent
#346
Question
core-project issues access and refresh JWTs as bearer tokens stored client-side, with the refresh token in Redis keyed by user — one live session per user. For a same-origin web app: JWT in httpOnly cookies, but where does the refresh token live (Postgres or Redis), how do several devices coexist, how is a session revoked (sign-out, password reset, account deletion), and is CSRF covered by the origin guard (ADR 0028) plus SameSite? Ends in an ADR.
Resolution
ADR 0030, PR #356.
sessionsrow per signed-in browser: the SHA-256 hash of the refresh token, created_at, last_used_at, expires_at and the user agent. An Account has any number of them. No Redis: a Session is Account data that cascades on deletion, and a refresh every 15 minutes per browser is no load. Whether Rooms move to Redis is a separate question, now noted in the map's fog.sub(the Account) andsid(the Session), HS256 with a secret per stack. Revocation lags by at most 15 minutes. A deleted Account is refused at once, because authenticated procedures load it.auth.refresh, then retries the call once. Nothing is refreshed transparently in middleware.__Host-access:Secure; HttpOnly; Path=/; SameSite=Lax.__Secure-refresh:Secure; HttpOnly; SameSite=Strict, its path limited to the refresh procedure.Domainattribute, so production and the previews never receive each other's cookies.pr-N.chess.core-project.spaceor other*.core-project.spaceapps, which are same-site with production. It holds while two invariants hold: no GET procedure changes state, and no CORS is opened.Left to the Accounts v1 spec: the oRPC auth contract (core-project's shape), pruning expired Session rows, and the exact source paths, which the ADR's Governs column guesses as
apps/api/src/auth/**andapps/front/src/auth/**.mentioned in issue #351
mentioned in issue #352
mentioned in issue #346
marked this issue as related to #346
marked this issue as related to #352
marked this issue as related to #351