dev_arc_aws/src/pages
Samuel James d863448495
Add auth Phase 3: multi-user accounts with admin/member roles (#28)
Implements Phase 3 of the auth roadmap: multiple user accounts (cap 10),
an admin/member role model, and admin-only gating of config-mutating
routes. Dashboard data stays shared across all users (per the product
decision in HANDOFF.md — this is a household/self-hosted dashboard, not
a multi-tenant app), so there is no per-user data isolation.

Schema (backend/src/db/index.ts):
- Idempotent migration adds `role` (default 'admin') and `active`
  (default 1) columns to `users` when missing. The 'admin' default means
  the pre-existing single user is backfilled to admin on deploy and keeps
  full access; newly created users are inserted explicitly as 'member'.
  Verified against a production-like old schema (columns added, existing
  user backfilled to admin/active).

Auth + access control:
- `/api/setup` creates the first user as admin. Login enforces `active`
  (deactivated accounts get 403) and embeds the live role in the session.
- `app.authenticate` now reads role+active fresh from the DB on every
  request (not from the possibly-stale JWT claim), rejects inactive
  accounts, and stashes the role on req.user.
- New `requireAdmin` (auth + role check) and `adminOnly` (role check for
  routes already behind the plugin-level authenticate hook) decorators.

User management (admin-only, in auth.ts):
- GET/POST/PUT/DELETE /api/users — list, create (admin sets a temp
  password; no public signup), change role, activate/deactivate, delete.
- 10-user cap enforced server-side; guard rails prevent removing the last
  active admin (demote/deactivate/delete) and deleting your own account;
  deactivating or deleting a user drops their sessions immediately.

Admin-only route gating (members get 403):
- integrations create/update/delete/test, tunnels create/delete, data
  export/import. Read routes and tunnel connect/disconnect stay open to
  all authenticated users, as do all the SSH/Docker/RDP tools and
  bookmarks (members are trusted to use the tooling, per product decision).

Frontend:
- api.ts: listUsers/createUser/updateUser/deleteUser + ManagedUser type;
  role+active added to AuthUser.
- Settings: new admin-only "Users" section (create form, role toggle,
  activate/deactivate, delete, 10-cap indicator). Nav filters the Users
  tab by role and guards ?tab= deep-links. Data & Backup shows an
  admin-only notice for members; Integrations shows a read-only banner
  for members. (Backend remains the real enforcement boundary.)

Verified end-to-end against a throwaway backend: role assignment,
member 403s on every admin-only route + 200s on shared/read routes,
admin 200/201s, last-admin guards (409/400), deactivation killing an
active session and blocking re-login (then reactivation restoring it),
and the 10-user cap (409 on the 11th). Both frontend and backend
type-check clean.

Co-authored-by: Samuel James <ssamjame@amazon.com>
Co-authored-by: Kiro <noreply@kiro.dev>
2026-06-20 12:43:24 -04:00
..
BookNest.tsx Add bulk delete-all for bookmarks (#20) 2026-06-20 09:09:44 -04:00
Containers.tsx Fix page titles, dropdown stacking, bookmark editing, and button/select polish 2026-06-19 21:34:04 +00:00
Enrollment.tsx Add enrollment, login, and auth-gated routing to the frontend 2026-06-18 19:13:27 +00:00
Files.tsx Fix page titles, dropdown stacking, bookmark editing, and button/select polish 2026-06-19 21:34:04 +00:00
Glance.tsx Add client-side routing and build Infrastructure page 2026-06-18 16:15:34 +00:00
Help.tsx Fix favicon, dark select dropdowns, add brand bookmark icons and Help page 2026-06-19 21:13:32 +00:00
HostMetrics.tsx Add host metrics widgets (Phase 6): CPU/mem/disk/network/processes/ports/firewall/login dashboard 2026-06-19 15:38:30 +00:00
Infrastructure.tsx Use network-traffic background for Integration Health card (#11) 2026-06-20 07:15:32 -04:00
Login.tsx Add enrollment, login, and auth-gated routing to the frontend 2026-06-18 19:13:27 +00:00
RemoteDesktop.tsx Phase 5: RDP/VNC/Telnet remote desktop via guacamole-lite + guacd 2026-06-19 15:25:10 +00:00
Settings.tsx Add auth Phase 3: multi-user accounts with admin/member roles (#28) 2026-06-20 12:43:24 -04:00
Terminal.tsx Phase 1c: OPKSSH cert auth, tmux session monitor/reattach, session logging 2026-06-19 11:28:51 +00:00
Tunnels.tsx Phase 2: SSH tunnels (local/remote/dynamic SOCKS5 port forwarding) 2026-06-19 11:40:59 +00:00