fabro/lib/foundation/fabro-db
Bryan Helmkamp c69a47c4e6
Add auth_sessions and refresh_tokens schema
A CLI auth session is a rotation chain, but the SlateDB records that back
it today store identity and profile per token, so a chain has no owner and
nothing stops its rows from disagreeing. These two tables give the chain a
home: `auth_sessions` holds the identity and profile once, `refresh_tokens`
holds only per-token facts.

Two invariants the current code relies on but never states become
constraints. The partial unique index on `(session_id) WHERE used_at_ms IS
NULL` enforces that rotation leaves exactly one live token per chain --
which is what makes the session listing an indexed lookup instead of a
scan-and-group. The foreign key with `ON DELETE CASCADE` makes revoking a
session remove its tokens without a second statement.

Tokens are retained after rotation until they expire so a replayed token
stays distinguishable from a forgery.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-07-25 15:15:58 -04:00
..
migrations Add auth_sessions and refresh_tokens schema 2026-07-25 15:15:58 -04:00
src refactor: organize crates into three layers 2026-07-23 17:59:34 -04:00
tests Add auth_sessions and refresh_tokens schema 2026-07-25 15:15:58 -04:00
Cargo.toml refactor: organize crates into three layers 2026-07-23 17:59:34 -04:00