Skip to content

Commit 32df23d

Browse files
committed
docs: define enterprise account and org management model
1 parent 6157ee2 commit 32df23d

7 files changed

Lines changed: 94 additions & 1 deletion

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ OpenComments is currently transitioning from a hackathon prototype to a producti
1919
- Delivery tracking: [`docs/plan/README.md`](docs/plan/README.md)
2020
- Milestones: [`docs/plan`](docs/plan)
2121
- Current focus: schema reconciliation, RBAC/multi-tenancy hardening, agency workflow completion, quality gates
22+
- RBAC and account model: [`docs/RBAC_ACCOUNT_ORG_MANAGEMENT.md`](docs/RBAC_ACCOUNT_ORG_MANAGEMENT.md)
2223

2324
## 🏛️ Project Purpose
2425

@@ -125,6 +126,7 @@ Before deploying, ensure quality gates pass:
125126
- **[DATAMODEL.md](docs/DATAMODEL.md)** - Database schema and relationships
126127
- **[API_V1.md](docs/API_V1.md)** - Public and agency API contract (v1)
127128
- **[DATA_DICTIONARY.md](docs/DATA_DICTIONARY.md)** - Canonical domain field definitions
129+
- **[RBAC_ACCOUNT_ORG_MANAGEMENT.md](docs/RBAC_ACCOUNT_ORG_MANAGEMENT.md)** - Enterprise role, account, and organization management model
128130
- **[AGENCY_ONBOARDING.md](docs/AGENCY_ONBOARDING.md)** - First-time agency setup guide
129131
- **[AGENCY_ADMIN_GUIDE.md](docs/AGENCY_ADMIN_GUIDE.md)** - Guide for government staff
130132
- **[PUBLIC_USER_GUIDE.md](docs/PUBLIC_USER_GUIDE.md)** - Guide for citizens

docs/ARCHITECTURE.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,12 @@ OpenComments is a shared multi-tenant public comment platform:
99
- Supabase Edge Functions for async jobs and notifications
1010
- Netlify static hosting
1111

12+
Core security and governance model:
13+
14+
- Shared multi-tenant data model with agency-scoped RLS policies.
15+
- Enterprise RBAC for agency and platform administrators.
16+
- Account/profile self-service with guarded fields and role-safe organization management workflows.
17+
1218
## Primary Personas
1319

1420
- Public commenters

docs/DATAMODEL.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ OpenComments uses PostgreSQL with Supabase's Row Level Security (RLS) to ensure
88

99
## 📋 Core Entities
1010

11+
> Canonical role and account governance behavior is defined in `docs/RBAC_ACCOUNT_ORG_MANAGEMENT.md`.
12+
> This document focuses on relational structures and RLS patterns.
13+
1114
### User Management
1215

1316
**profiles**
@@ -584,4 +587,4 @@ FOR EACH ROW EXECUTE FUNCTION update_docket_search_vector();
584587

585588
---
586589

587-
**See also**: [ARCHITECTURE.md](ARCHITECTURE.md), [DEVELOPER.md](DEVELOPER.md)
590+
**See also**: [ARCHITECTURE.md](ARCHITECTURE.md), [DEVELOPER.md](DEVELOPER.md)
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
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.

docs/plan/M02-auth-rbac-and-multi-tenancy.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ Implement real agency membership and permission checks with tenant isolation.
77
- Replace mocked permission and agency context hooks with DB-backed lookups.
88
- Enforce role-aware behavior in app logic.
99
- Add/validate RLS for agency-isolated resources.
10+
- Harden account and role-management guardrails in RPCs.
11+
- Provide self-service profile management for all agency members.
1012

1113
## Out of scope
1214

@@ -19,11 +21,15 @@ Implement real agency membership and permission checks with tenant isolation.
1921
- [x] Update permissions hook to use real memberships.
2022
- [x] Ensure platform roles are loaded from `platform_roles`.
2123
- [x] Add tests for tenant isolation assumptions.
24+
- [x] Add explicit role-assignment/status-change guardrails (owner/admin boundaries, last-owner protections, self-change protections).
25+
- [x] Add account profile self-service update flow backed by `profiles` with secure field protection.
2226

2327
## Acceptance criteria
2428

2529
- [x] Agency routes use actual membership data.
2630
- [x] Permission gating no longer depends on mock role mapping.
31+
- [x] Manager role cannot administratively manage users/settings outside docket/moderation scope.
32+
- [x] Role/status change APIs prevent unsafe operations (self-deactivation, removing last owner, unauthorized role elevation).
2733

2834
## Risks/blockers
2935

@@ -40,3 +46,5 @@ Implement real agency membership and permission checks with tenant isolation.
4046
- 2026-02-11: Updated permission hook to derive role/capabilities from real membership records with legacy fallback behavior only when needed.
4147
- 2026-02-11: Updated auth context bootstrapping to load `platform_roles` during session initialization.
4248
- 2026-02-11: Added `tests/tenant-isolation-policies.test.js` to verify RLS enablement and tenant predicates exist across agency-scoped tables.
49+
- 2026-02-11: Added migration `20260211000600_rbac_account_management_hardening.sql` to tighten `is_agency_admin` semantics (owner/admin only), enforce enterprise role/status guardrails in membership RPCs, and protect restricted profile fields from self-escalation.
50+
- 2026-02-11: Expanded agency user experience with self-service profile management and role-permission catalog while retaining admin workflows for invite/role/status/ownership management.

docs/plan/M03-agency-operations.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ Replace mock agency workflows with real data operations.
77
- Docket list/detail/create flows.
88
- User management routing and role workflows.
99
- Moderation queue functionality.
10+
- Organization ownership transfer and account access UX.
1011

1112
## Out of scope
1213

@@ -18,11 +19,14 @@ Replace mock agency workflows with real data operations.
1819
- [x] Remove high-visibility "coming soon" placeholders in core agency routes.
1920
- [x] Connect docket pages to real Supabase tables/RPCs.
2021
- [x] Ensure moderation queue reads/writes real moderation data.
22+
- [x] Provide non-admin self-service account/profile experience in agency portal.
23+
- [x] Provide owner ownership-transfer workflow in agency portal.
2124

2225
## Acceptance criteria
2326

2427
- [x] Agency can create and manage dockets without mock data.
2528
- [x] Agency moderation actions persist and are auditable.
29+
- [x] Agency staff can manage profile/access clearly from one consistent Users & Access screen.
2630

2731
## Risks/blockers
2832

@@ -44,3 +48,4 @@ Replace mock agency workflows with real data operations.
4448
- 2026-02-11: Replaced mock agency dashboard data in `src/pages/agency/AgencyDashboard.tsx` with real agency analytics, moderation queue, and docket summary queries.
4549
- 2026-02-11: Replaced mock docket detail workflow in `src/pages/agency/DocketDetail.tsx` with real Supabase reads/writes, moderation actions, supporting-document retrieval, and audit/moderation activity history.
4650
- 2026-02-11: Implemented real docket edit-mode behavior in `src/pages/agency/DocketWizard.tsx`, including preload/update of existing docket settings and additive supporting document uploads.
51+
- 2026-02-11: Upgraded `src/pages/agency/UserManagement.tsx` into a unified Users & Access experience with profile self-service, explicit permission catalog, role catalog, admin team management filters, and owner ownership transfer.

docs/plan/M07-ux-accessibility-and-design-system.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,3 +40,4 @@ Consolidate UX architecture and enforce accessible, coherent UI patterns.
4040
- 2026-02-11: Expanded `docs/ACCESSIBILITY_TRACKER.md` with a concrete WCAG 2.1 AA verification checklist for primary public and agency workflows.
4141
- 2026-02-11: Removed unused legacy pages (`src/pages/AgencyDashboard.tsx`, `src/pages/AgencyLogin.tsx`) that contained stale placeholder/duplicate agency UI, leaving canonical `/pages/agency/*` surfaces as the single implementation path.
4242
- 2026-02-11: Added Playwright + Axe automated accessibility baseline (`tests/playwright/accessibility.pw.ts`) and verified no `critical` violations on primary entry routes; recorded in `docs/ACCESSIBILITY_TRACKER.md`.
43+
- 2026-02-11: Refined `Users & Access` IA so all agency roles have a single profile/access surface, with admins getting advanced management controls and role catalog context in the same page.

0 commit comments

Comments
 (0)