Multi-user sign-in with role-based access control (RBAC) #1
Labels
No labels
priority/high
priority/low
priority/medium
type/feature
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
ben/career-values-cards#1
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?
Replace the open, no-login model with real accounts.
Scope
admin(practice staff/counsellor) andclient; considerownerfor practice-level settings.Acceptance
Blocks: admin dashboard, invites, activity builder. Note: client values/notes are sensitive personal data; privacy obligations (e.g. PIPEDA / provincial health privacy rules) should be confirmed with the practice.
Handoff context: the app is being prepared so a counselling practice can self-host it (see README and docs/self-hosting.md). Today the app has no auth by design, two hard-coded decks in
shared/cards.json, three fixed columns, and Fastify + SQLite + SSE sync (docs/api.md).Filed during handoff prep (README and docs/self-hosting.md in
c133282). No implementation yet. Recommended order: #2 (activities data model + migration) before #1 (RBAC), pending the maintainer's confirmation.Maintainer decisions, 2026-10-13:
#2 is done (
7a4378c). Two seams are ready for authorization checks:resolveSessionActivity()andlistAccessibleSessions()in server/app.js, plus thesession_activitiestable for assignment.Maintainer decisions, 2026-10-13:
owner(practice settings and staff),admin(counsellor, manages their clients),client(own sessions only).Plan written and reviewed by a High panel (3/3 voices):
docs/plans/2026-10-13-14-50_rbac-sign-in-and-smtp-outbox.md. More decisions: counsellors are view-only by default (ADMIN_CAN_EDITflag); privacy guidance gates real-client use rather than the release; the source PDFs stay private. No code yet.Slices 1–3 of the plan landed on main, each after a High-tier review (codex, deepseek, qwen) with all findings fixed. Not deployed yet; the release is atomic after slice 6.
380c525: explicit migration dispatch, M3 accounts schema plus archiving every session, users.js, CLI bootstrap-owner and assign-session.7dd3ea5: SMTP outbox (#3).7ecfb95: auth.js. Hashed cookie sessions, magic-link and invite consume, argon2id passwords, CSRF, rate limits, default-deny on all non-public routes including SSE, CLI login-link.538 server tests pass.
Left: slice 4 (policy.js and tenant isolation; for now any signed-in user sees every session), slice 5 (management API), slice 6 (web), slice 7 (docs and release).
Open: the argon2 prebuilt hasn't been verified in the slim image yet (no local Docker).
Slice 4 (policy enforcement) landed in
f090295after a High review (codex gpt-6-astra, deepseek, qwen; 3/3) and two delta rounds, the last clean.Left: slice 5 (management API), slice 6 (web), slice 7 (docs and release). Not deployed.
Slice 5: the management API landed in
b93fd31. It had a High review (codex gpt-6-astra, deepseek and qwen; 3/3), two delta rounds and a final deepseek gate check.Decision (maintainer, 2026-10-14): an admin creating a client can learn whether the email already has an account (409; nothing is ever relinked). Accepted as residual risk: admins are trusted staff, and the attempt is rate-limited and audited.
Left: slice 6 (web sign-in and the role-aware UI), slice 7 (docs and release). Not deployed.
Deferred from the slice 6 review (maintainer, 2026-10-14): a note-save race in the web client.
openSessionrestores the stored draft into memory. The late acknowledgement releases only the stored copy, so the retry resends the acknowledged value. That could overwrite a newer edit made elsewhere.Slice 6 and docs:
683a5d3: slice 6, the web client.#/authview that scrubs the token from the address bar.POST /api/auth/passwordacceptsuserId, and a mismatch gives 409.4a4d07b: docs rewritten for IT administrators. Self-hosting covers configuration, SMTP, first owner, users, backups, upgrades, privacy checklist and troubleshooting. The deployment guide has the release procedure. The API reference covers auth and management. The README has screenshots. Compose now passesADMIN_CAN_EDIT.Still open: slice 7 (High release review, dry run, atomic deploy, owner bootstrap, smoke test) and the deferred note-save race (see the comment above). Not deployed.
Released and deployed (live at schema v5 from
568d5e9, with the maintainer's approval).2fe94d4: the note-save race is fixed with per-note draft revisions, serialized writes and snapshot reconciliation. Release-review fixes:Follow-up fixes landed in
654bca2and are deployed (live at8db0a97, schema v5, no migration).req()callers whose responses can go stale now pass a request-current predicate, and stale responses are dropped before the 401 sign-out and draft-clearing side effects. This covers builder list/read/reload and access history.Verified: 1163 server tests, 484 web unit tests and 6 Playwright journeys pass. Live smoke checks: signed-out requests get 401, healthz ok, the new client bundle is served.
Medium review: codex, plus kimi-k3 substituting for deepseek. Two delta rounds, clean.
Left: close the RBAC plan, then close this issue after checking its acceptance against the live app.
Acceptance verified, closing.
server/auth.jsand all role rules inserver/policy.js. On the live app, signed-out requests to/cards/api/sessionsand/cards/api/auth/mereturn 401.server/test/policy-matrix.test.jscompares registered routes (including auto-HEAD) with the policy table in both directions. For bothADMIN_CAN_EDITvalues, it checks every actor against every resource, including a foreign client, an unlinked admin and a disabled or anonymous user, and confirms data is unchanged after each denial. SSE revocation is covered insse-auth.test.js.main: 1163 server tests, 484 web unit tests (95% line coverage) and 6 Playwright journeys pass.The plan
docs/plans/2026-10-13-14-50_rbac-sign-in-and-smtp-outbox.mdis closed (Status: done).BASE_PATHsupport. Since2fe94d4, startup requires/cards.ADMIN_CAN_EDITis parsed loosely; a typo leaves counsellors view-only.