feat(supabase): db:trial grants owner with one verified TOTP factor

Owner decision 2026-11-11: on the trial stack one verified factor suffices
for owner as for admin, a second one optional. The count before the typed
confirmation and the recount inside the grant transaction stay; SQL, aal2
and the rule for every other stack are unchanged.
This commit is contained in:
bchanot committed 2026-11-11 22:37:40 +01:00
1 parent 0573d66864
commit 45d74536f5
4 files changed
+30 -18

No files matched your search

+5 -4
View File
@@ -864,16 +864,17 @@ before any Docker call. Their typed confirmations: `destroy` asks `faunosteo_tri
| `rotate-keys` | a backup, then new anon and service keys signed with the same secret (one more year), Storage recreated and the gateway restarted; works on a stopped stack too (Storage is then recreated by the next `start`); the previous keys stay valid until their own expiry. Expired keys never block `start` or `rotate-keys`; `app`, `assets` and `account` refuse them and name `rotate-keys`; `status` reports them |
| `rotate-secrets` | a backup, then a new JWT secret, keys and role passwords set in one transaction as `supabase_admin` (values through psql variables, statement and error-statement logging off, a digest marker proving the commit); the new values wait in `secrets.next.env` (600) until the commit is known; every container recreated; access tokens signed with the old secret are refused, while refresh tokens and sessions stay valid (a signed-in browser keeps its pre-rotation access token and gets 401 from PostgREST, even after an app restart, until auth-js refreshes it near its expiry, up to 3600 s, or the user signs out and in again; the script revokes no session, which is an owner decision not taken; to end sessions after a rotation, sign in again, then sign out: see the paragraph below the table), account passwords and TOTP factors stay |
| `account <email>` | a confirmed account through GoTrue's admin API on 58999, password typed twice at a hidden prompt (12 characters min.); the address is lowercased |
| `grant <email> <right>` | `owner` / `admin`: the operator path of the V1-2 contract §5.7.1 (verified TOTP factors shown, two for owner, one for admin; typed confirmation `grant <right>`; `private.assign_platform_role(null, …)` and an audit row); a platform role already active is refused. Catalogue rights mirror `public.grant_catalog_right` in operator SQL (the RPC needs an owner session at aal2): a confirmed active account; a verified TOTP factor for every right but `catalog_reader`; `admin` held first for `sheet_editor` and `sheet_publisher` (the refusal names `pnpm db:trial grant <email> admin`); one active row per right; typed confirmation; the insert and an audit row `catalog_grant.operator_bootstrap` in one transaction; no platform role is granted implicitly. `granted_by` is the holder's own id (the column is NOT NULL and the operator has no profile), so the rights screen shows a self-grant; the audit row names the operator. A catalogue right already active exits 0 with nothing written |
| `grant <email> <right>` | `owner` / `admin`: the operator path of the V1-2 contract §5.7.1 (verified TOTP factors shown, one for owner and for admin (owner decision 2026-11-11; a second factor is an optional backup); typed confirmation `grant <right>`; `private.assign_platform_role(null, …)` and an audit row); a platform role already active is refused. Catalogue rights mirror `public.grant_catalog_right` in operator SQL (the RPC needs an owner session at aal2): a confirmed active account; a verified TOTP factor for every right but `catalog_reader`; `admin` held first for `sheet_editor` and `sheet_publisher` (the refusal names `pnpm db:trial grant <email> admin`); one active row per right; typed confirmation; the insert and an audit row `catalog_grant.operator_bootstrap` in one transaction; no platform role is granted implicitly. `granted_by` is the holder's own id (the column is NOT NULL and the operator has no profile), so the rights screen shows a self-grant; the audit row names the operator. A catalogue right already active exits 0 with nothing written |
| `assets` | the equine drawings with `pnpm assets:upload` through the gateway (no overwrite, rerun = nothing to do), then every row confirmed with its object |
| `app` | the app, foreground; Ctrl+C stops Vite and waits for it, so 5194 is free on return; the stack keeps running |
| `destroy` | inventory, typed confirmation `faunosteo_trial`, a backup of every trial volume checked as a restorable backup, then the containers, the network, the volumes and the live state files; backups kept. When that backup cannot be made or fails the check, it removes nothing and names the backup kept (or none), the exact `docker rm`, `docker network rm` and `docker volume rm` lines for what exists, then `pnpm db:trial destroy` to clear the state files; the script never runs those lines. With no trial resource left, it removes the live state files only |
First use, after the owner's go: `plan`, `create`, `assets`, then the two accounts.
1. Owner/admin account, for the administration trials: `account <email>`, `app`, sign in, enrol two TOTP
factors in Mon compte > Sécurité, then `grant <email> owner`, `grant <email> admin`, then `grant <email>
sheet_editor`, `sheet_reviewer` and `sheet_publisher`; sign in again and pass the step-up.
1. Owner/admin account, for the administration trials: `account <email>`, `app`, sign in, enrol one TOTP
factor in Mon compte > Sécurité (a second is an optional backup), then `grant <email> owner`, `grant <email> admin`, then `grant <email>
sheet_editor`, `sheet_reviewer` and `sheet_publisher`; sign in again and pass the step-up. With one factor, a lost device
means the operator recovery of V1-2 §5.7.7 at the trial database, or a new account granted through `grant`.
2. Practitioner account: `account <email>`, `app`, enrol one TOTP factor, `grant <email> admin`, then `grant <email>
sheet_editor` (refused before `admin`). This is a trial account, not a production practitioner profile: the
technical `admin` role is there only because rule O1 activates `sheet_editor` for a platform admin (hence the
+7 -1
View File
@@ -413,7 +413,8 @@ A1 to A6):
(residual, §13). V1-2.5 records what removing a factor does to the
account's other open sessions.
- Loss of a factor: Supabase Auth issues no recovery codes. The owner enrols
two factors on two devices before the first grant on any stack. Another
two factors on two devices before the first grant on any stack (db:trial
exception: §5.7.1). Another
account that loses its factor keeps its `aal1` access (catalogue, rest of
the application) and loses the administration until recovery.
- Recovery is an operator procedure, never an application feature: no RPC,
@@ -550,6 +551,11 @@ the reverse:
API, email confirmed, and hands over the initial secret out of band;
2. the future owner signs in, enrols two TOTP factors on two devices and
verifies both; no role exists yet, so nothing is at stake in the window;
(db:trial exception, owner, 2026-11-11: on the persistent trial stack of
`pnpm db:trial` one verified TOTP factor suffices for the owner grant, as
for admin; a second factor is an optional backup. This rule, for every
other stack, production included, is unchanged until a distinct study and
authorisation.)
3. the operator checks, read-only, that the account has verified factors and
that their names and creation times match what the owner did;
4. only then the operator assigns the owner role from a privileged SQL