Decisions — identity
This page is generated from the project corpus and rewritten on every docs build. Edit the source in corpus/, not here.
Split out of decisions.md on 2026-10-04, when that page passed ~200 lines (corpus/CLAUDE.md). Unchanged in the move. Same rule: a change needs an explicit revisit and a log.md entry.
Auth (locked 2026-06-28 — SUPERSEDED 2026-09-06, see "Identity is Ward's" below)
Every bullet in this section describes machinery prm no longer has. It is kept because the reasoning still explains why prm has end-user accounts at all, which the replacement inherited unchanged; only the implementation moved.
- Full end-user auth is in scope now (not deferred), because favorites + notifications are the retention loop the POC is meant to demonstrate — not just admin gating. (Re-confirmed 2026-06-28 against the POC reframe: kept deliberately, as a demoed feature.)
- Email + password, self-hosted — matches the house style of hand-rolling over dependencies (better-sqlite3, no UUID lib, Zod). No managed provider (Clerk/Auth0) for v1.
- Hashing: argon2id (or bcrypt) — never plaintext/SHA.
- Sessions: opaque session id in an httpOnly + Secure + SameSite cookie, stored server-side in SQLite. Not a JWT in localStorage (XSS-stealable). Use
@fastify/cookie. - Verify + reset flows are built now, but email delivery is console-logged links in dev; swap in a transactional email provider (Resend/Postmark/SES) before launch.
- The Navbar profile dropdown is currently decorative; it becomes real when auth lands.
Identity is Ward's (locked 2026-09-06 — supersedes "Auth" above; SUPERSEDED 2026-10-13, see "prm owns its accounts" below)
- prm authenticates nobody. The
user,session,verification_tokenandreset_tokentables are dropped;plugins/auth.ts,routes/auth.ts,lib/auth-internals.ts,lib/ensure-admin.tsand the login/register screens are deleted. prm holds no credential of any kind — no password hash, no session id, no reset token. Sign-in, registration, email verification and password reset are Ward's (wzd_auth/corpus/wiki/overview.md), at one login page for the estate. - prm is the reason Ward has public registration at all. The estate's first
design had no self-signup; prm ships it, and that collision is what moved the
security boundary from registration to authorization. Anyone may hold a
Ward account; a grant is what lets them reach anything. prm's app row is
the only one in the estate with
public_registrationon, and registering at/ward/register?app=prmconfers exactlyprm:userand nothing anywhere else. - Roles became grants.
user.roleis gone. Authority is the Ward triple(subject, "prm", role); Ward stores it and never interprets it.requireAuthnow means holds a prm grant, not merely has a session — a live Ward account with no prm grant is not signed in as far as prm is concerned, which is exactly what keeps open registration here from opening atrium.prm:admindoes not implyprm:user: grants are a set, not a ladder, sorequireAuthaccepts either explicitly rather than assuming a hierarchy Ward does not have. emailVerifiedwas never prm's. It is an account-level fact, not an app-level one, and Ward records it once instead of every app recording it separately.- Per-person rows are re-keyed onto the subject.
favorite_place,favorite_eventandnotificationswapuser_idforsubject— an opaque Ward identifier, with no foreign key, because the table it would reference does not exist here and a localusertable would be a second, stale answer to "who exists". - Nothing is gated by default, and that is deliberate. Every other app in
the estate gates its whole surface; prm is a public resource map and does
the opposite. The root hook resolves a session only when a cookie is present
and leaves the request anonymous otherwise;
requireAuth/requireAdminstay opt-in per route. Revised 2026-10-06 (owner), built 2026-10-07 (Ward-only-where-needed): there is no root hook.resolveWardresolves a request's session at most once, and only the guards and/api/mecall it. Why: theward_sessioncookie is estate-wide, so anyone signed in to any estate app made every public-map request wait on Ward, up to its 5 s timeout when Ward was slow. A consequence worth keeping: when Ward is down, the public map still works, because it never asks Ward anything. Guarded routes answer 503 and fail closed. "Ward is down" includes Ward's key set being unreachable (2026-10-03): a failure to fetch or read the JWKS isWardUnavailableError, not an invalid token; only "no key matches this token'skid" stays a 401. The client's injectedfetchreaches the key set too (jose'scustomFetch), so tests cover that path. - prm hand-writes its Ward client (
backend/src/ward/) rather than importing a shared package — the estate decided against one because these repos are separate checkouts thatnpm ciindependently. The contract iswzd_auth/corpus/wiki/integrating.md. - There is no seeded admin.
ensureAdminpromoted an account fromADMIN_EMAIL/ADMIN_PASSWORDon every boot;prm:adminis now issued by hand from Ward's console. An admin a redeploy can recreate is an admin an environment variable can silently grant. - The cutover destroys every account and everything keyed on one — the
favourites and notifications go with them. prm keyed people on email and
Ward keys them on a minted subject, so no mapping exists that was not invented
at cutover time; the estate chose a full prune. Places, events, sources and
the geocode cache are untouched. Take a database copy first —
0001_ward_cutover.sqlhas no down.
prm owns its accounts; Ward is a linked second way in (locked 2026-10-13 — supersedes "Identity is Ward's")
The estate's redesign (Ward's decisions-oidc.md (wzd_auth/corpus/wiki/decisions-oidc.md)),
built here on 2026-10-13. Each app keeps its own accounts and login page;
"Sign in with Ward" is an OpenID Connect button beside the form.
- Accounts are prm's again, from Ward's shared library, vendored as a
built copy in
backend/vendor/wardandui/vendor/ward(never edited; upgraded by vendoring a newer build). Its tables (auth_users,auth_sessions,auth_ward_links) live in prm's SQLite beside prm's own. Scrypt passwords, opaque server-side sessions in theprm_sessioncookie (HttpOnly,SameSite=Lax,Path=/prm-api). Local sign-in never calls Ward, so prm works while Ward is down. - prm is the one app with a register page, and it is prm's own (owner,
2026-10-13): username and password, no email, role
user. Ward holds the addresses, so mail reaches only Ward-linked users; settings says so. - Roles are prm's.
userandadminlive inauth_users.role. A Ward grant decides only whether a Ward account may use the button, and gives a user created by a first Ward sign-in their first role (adminstaysadmin, anything else becomesuser).db:seed-userscreates users from the environment or a prompt;db:set-rolechanges a role. - Public by allowlist. The library guards every route that
backend/src/ward/auth.tsdoes not list: the map's reads,/healthand the plugin's own sign-in routes are public, and everything per-person or admin is signed-in by default. A public route never resolves a session, so/api/meis gone; the UI asksGET /prm-api/auth/session. - Rows keep their keys.
favorite_place,favorite_eventandnotificationkeep theirsubjectcolumn, which now holds a local user id. On boot, every key no local user has (the Ward subjects from before) becomes a user whose id is that subject, linked to it, so the person's next Ward sign-in finds their rows. prm never stored usernames or roles, so a migrated user isuser-<first 8 characters>with the roleuser; a former admin is promoted withdb:set-role. No Drizzle migration: the library migrates its own tables, and this step is code (backend/src/ward/subjects.ts). - Revoke-everywhere holds for Ward sessions only: a session that began
with Ward is checked against Ward at most every 30 seconds and refused
(
ward_unavailable) when Ward cannot answer; a local session is never checked. - Rejected: keeping Ward as the only identity (the 2026-09-06 shape). It made prm's sign-in die with Ward and gave prm a login page that was not its own. Also rejected: matching a Ward account to a local one by username: linking happens only from settings, signed in.