You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 7ba2717
Browse filesBrowse the repository at this point in the historyBrowse files
docs(specs): sessions stick for 90 days and the SPA renews them
The SPA never called /api/auth/refresh, so every session ended with the
15-minute access cookie. Spell out the client's job (refresh on load
behind a non-secret hint cookie, and once on any 401), lengthen the
sliding refresh window to 90 days, and say refresh writes nothing to
the public store.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01TGqwPjt3v4eMfiHpPmCKnR
Copy file name to clipboardExpand all lines: specs/api/conventions.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -71,7 +71,7 @@ For paginated lists, the `data` is an array and `metadata` includes pagination:
71
71
72
72
## Authentication
73
73
74
-
- Two cookies carry **stateless JWTs**: `cfp_session` (15-minute access JWT) and `cfp_refresh` (30-day refresh JWT, path-scoped to `/api/auth/refresh`). Cleared by `POST /api/auth/logout`. See [behaviors/authorization.md](../behaviors/authorization.md) for the full token model and [api/auth.md](auth.md) for the surviving session endpoints.
74
+
- Two cookies carry **stateless JWTs**: `cfp_session` (15-minute access JWT) and `cfp_refresh` (90-day refresh JWT, path-scoped to `/api/auth/refresh`), plus the non-secret `cfp_has_session` hint. Cleared by `POST /api/auth/logout`. See [behaviors/authorization.md](../behaviors/authorization.md) for the full token model and [api/auth.md](auth.md) for the surviving session endpoints.
75
75
- Both cookies: `HttpOnly`, `Secure`, `SameSite=Lax`. In development, `Secure` is dropped when the host is `localhost`.
76
76
- There is no `sessions` table or sheet. Revocation is tracked in a small `revocations` sheet plus an in-memory `Set` of revoked `jti`s.
77
77
- The endpoints that *issue* JWTs (GitHub OAuth callback, account-claim flow) are not yet specified. The endpoints that *manage* JWTs once issued are in [api/auth.md](auth.md).
Copy file name to clipboardExpand all lines: specs/behaviors/authorization.md
+14-4Lines changed: 14 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -64,9 +64,10 @@ Sessions are **stateless JWTs**, not database rows. There is no `sessions` sheet
64
64
### Tokens
65
65
66
66
-**Access JWT** — 15-minute lifetime. Sent on every API request in the `cfp_session` cookie. Payload: `{ sub: personId, jti: uuidv7, accountLevel, exp, iat }`.
67
-
-**Refresh JWT** — 30-day lifetime. Sent only on refresh requests in a separate `cfp_refresh` cookie (path-scoped to `/api/auth/refresh`). Payload: `{ sub: personId, jti, exp, iat }`.
67
+
-**Refresh JWT** — 90-day lifetime. Sent only on refresh requests in a separate `cfp_refresh` cookie (path-scoped to `/api/auth/refresh`). Payload: `{ sub: personId, jti, exp, iat }`. Every refresh issues a new one, so the 90 days run from the last visit, not from sign-in.
68
+
-**Session hint** — a `cfp_has_session=1` cookie set and cleared alongside the refresh cookie, with the same lifetime, path `/`, and **not**`HttpOnly`. It carries no secret; it only tells the SPA a refresh is worth attempting, so anonymous visitors never trigger one.
68
69
69
-
Both cookies: `HttpOnly`, `Secure`, `SameSite=Lax`. `Secure` is dropped only when host is `localhost` in development.
70
+
The token cookies: `HttpOnly`, `Secure`, `SameSite=Lax`. `Secure` is dropped only when host is `localhost` in development.
70
71
71
72
Signing: HS256 with `CFP_JWT_SIGNING_KEY` (server-managed secret, rotated on a cadence). Rotation triggers re-issue of all tokens on next refresh.
72
73
@@ -77,7 +78,7 @@ GitHub OAuth callback resolves to a Person
77
78
(directly, or via /account-claim — see behaviors/account-migration.md)
78
79
│
79
80
▼
80
-
Issue access JWT (15m) + refresh JWT (30d) ─▶ Set cookies
81
+
Issue access JWT (15m) + refresh JWT (90d) ─▶ Set cookies
81
82
│
82
83
▼
83
84
Subsequent requests carry access JWT
@@ -90,7 +91,16 @@ GitHub OAuth callback resolves to a Person
90
91
91
92
There's a third short-lived JWT — the **claim-pending JWT** issued by the OAuth callback when legacy candidates exist. It has `scope: "claim"`, lifetime 5 minutes, and is accepted only by the `/api/account-claim/*` endpoints. See [api/account-claim.md](../api/account-claim.md).
92
93
93
-
The access-token TTL is intentionally short so revocation has a small blast radius. The refresh-token TTL is "session length" — 30 days of inactivity logs you out.
94
+
The access-token TTL is intentionally short so revocation has a small blast radius. The refresh-token TTL is "session length" — 90 days of inactivity logs you out; anyone who visits at least once a season stays signed in indefinitely.
95
+
96
+
**The SPA keeps the session alive.** The access cookie expires 15 minutes after it was issued and the browser drops it, so a returning member's first request arrives without one. The SPA therefore:
97
+
98
+
1. On load, when `/api/auth/me` reports no person but `cfp_has_session` is present, calls `POST /api/auth/refresh` once and re-reads `/api/auth/me`.
99
+
2. On any `401` from another API call (hint or not — a 401 means the caller tried something that needs a session), calls `POST /api/auth/refresh` once (concurrent 401s share one refresh) and retries the request; if the refresh fails, the `401` stands and the member is treated as signed out.
100
+
101
+
Signing in is the slowest thing a member does on this site, and a lapsed session silently turns their next action into a sign-in detour. Stay signed in unless they sign out or don't come back for a season.
102
+
103
+
**Refresh writes nothing to the public store.** It issues the new pair and swaps the private session-metadata entry; the old refresh token is not revoked — it stays valid until it expires, the same exposure as the token that replaces it (see [Why not refresh-rotation tracking](#why-not-refresh-rotation-tracking)). A revocation per refresh would be a public commit per active member every quarter hour.
0 commit comments