|
| 1 | +# RBAC, Account, and Organization Management |
| 2 | + |
| 3 | +This document defines the production RBAC and account-management model for OpenComments. |
| 4 | + |
| 5 | +## Agency Role Definitions |
| 6 | + |
| 7 | +| Role | Responsibility | Can manage users? | Can manage dockets? | Can moderate comments? | Can edit agency settings? | |
| 8 | +| --- | --- | --- | --- | --- | --- | |
| 9 | +| `owner` | Organization governance and final authority | Yes (all roles) | Yes | Yes | Yes | |
| 10 | +| `admin` | Operational administration | Yes (`manager`, `reviewer`, `viewer`) | Yes | Yes | Yes | |
| 11 | +| `manager` | Program operations for public-comment periods | No | Yes | Yes | No | |
| 12 | +| `reviewer` | Moderation workflow execution | No | No | Yes | No | |
| 13 | +| `viewer` | Read/export only | No | No | No | No | |
| 14 | + |
| 15 | +## Platform Roles |
| 16 | + |
| 17 | +| Role | Responsibility | |
| 18 | +| --- | --- | |
| 19 | +| `super_owner` | Full platform administration and super-user management | |
| 20 | +| `super_user` | Agency provisioning and invitation operations | |
| 21 | + |
| 22 | +## Enterprise Guardrails |
| 23 | + |
| 24 | +Database-enforced guardrails are implemented in `supabase/migrations/20260211000600_rbac_account_management_hardening.sql`: |
| 25 | + |
| 26 | +- Managers are excluded from agency-admin controls (`is_agency_admin` is owner/admin only). |
| 27 | +- Admins cannot assign or modify `owner`/`admin` members. |
| 28 | +- Users cannot deactivate their own agency membership. |
| 29 | +- APIs prevent removal/deactivation of the last active owner. |
| 30 | +- Role self-downgrades require ownership transfer flow. |
| 31 | +- Self profile updates cannot modify protected fields (`role`, `email`, `agency_name`) unless platform-admin. |
| 32 | + |
| 33 | +## Primary Workflows |
| 34 | + |
| 35 | +### 1. Member self-service |
| 36 | + |
| 37 | +- Route: `/agency/users` |
| 38 | +- All agency members can: |
| 39 | + - View their role and effective permissions. |
| 40 | + - Update profile display name. |
| 41 | + - Request elevated access through support workflow. |
| 42 | + |
| 43 | +### 2. Agency admin management |
| 44 | + |
| 45 | +- Owners/Admins can: |
| 46 | + - Invite users. |
| 47 | + - Change eligible roles within governance limits. |
| 48 | + - Activate/deactivate memberships within governance limits. |
| 49 | + - Review pending invitations and resend/revoke invites. |
| 50 | + |
| 51 | +### 3. Ownership governance |
| 52 | + |
| 53 | +- Owners can transfer ownership to another active member. |
| 54 | +- Transfer demotes existing owners to `admin` and promotes selected member to `owner`. |
| 55 | + |
| 56 | +## UI Surfaces |
| 57 | + |
| 58 | +- Agency navigation now exposes a unified `Users & Access` entry for all agency roles. |
| 59 | +- User dropdown includes `My Profile & Access` quick access. |
| 60 | +- Platform admin invitation flow uses live agency data instead of mock organization lists. |
| 61 | + |
| 62 | +## Verification |
| 63 | + |
| 64 | +Automated checks include: |
| 65 | + |
| 66 | +- `src/types/roles.test.ts` for role hierarchy/assignment contracts. |
| 67 | +- `tests/rbac-policy-contracts.test.js` for migration-level RBAC guardrail contracts. |
| 68 | +- `tests/tenant-isolation-policies.test.js` for tenant isolation policy assumptions. |
0 commit comments