by Ta-Tech Solutions All documents

Authentication & RBAC

How sign-in, roles, and row-level security work in CivicLoop County OS.

Sign-in flow

  1. Staff go to /[locale]/login, enter email + password (Supabase Auth).
  2. On success a session cookie (httpOnly) is set. requireStaff(locale, minRole) runs on every gated route/server action and redirects to /login (307) when there is no valid staff session.
  3. Sensitive surfaces can additionally require AAL2 (TOTP MFA via /mfa).
  4. Residents are never required to authenticate to file or track a 311 request.

Roles (ascending privilege)

Role Can do
agent Work the 311 queue, reply to residents, resolve with evidence
supervisor All agent rights + agency modules (KPIs + manage records) + data feeds + assistant
department_head Supervisor rights, scoped to their department
director County-wide dashboard, council views, automations
county_admin Admin console: staff, roles, 2FA status, locations

requireStaff takes a minimum role; a higher role satisfies a lower requirement.

Platform tier (TaTech engineers) - separate from tenants

The county boss is the tenant admin (county_admin, /admin). TaTech engineers are a separate tier: rows in platform_admins with access levels owner > engineer > support, gated by requirePlatformAdmin at /[locale]/platform (the Platform Console). They are not county staff and have no tenant role.

Row-Level Security (defense in depth)

Secret-gated machine endpoints (no user session)

Common outcomes

Situation Result
No staff session on a gated route 307 redirect to /login
Role too low redirect / not-authorized
Valid session, MFA required, not enrolled nudge to /mfa
Machine endpoint, secret unset 503 not_configured
Machine endpoint, wrong secret 401 unauthorized
PreviousAutomation & Triggers
CivicLoop - Ta-Tech Solutions - Architecture & Design Documentation