Add many-to-many matter participant authorization model
From the PR description
Motivation
- Enforce portal access using an explicit many-to-many
matter_participantstable so matter access is granted only to participants with the appropriate role rather than relying on implicit ownership or frontend hiding. - Apply consistent server-side and database-level (Supabase RLS) authorization across matter-scoped resources (matters, documents, portal messages, tasks, intake submissions, downloadable files) so clients/attorneys/reviewers/paralegals can only access matters they are assigned to while partners/admins have full access.
Description
- Added migration
backend/migrations/001_matter_participants_access.sqlto creatematter_participants(many-to-many matter <> user) withparticipant_roleconstraint and index. - Implemented SQL helpers
current_portal_role()andcan_access_matter(p_matter_id uuid)that check JWT role and membership inmatter_participants, granting global access topartner/adminand role-specific checks forclient,attorney,reviewer, andparalegal. - The migration dynamically enables RLS and creates select and all (read/write) policies on
matters,documents,portal_messages,tasks,intake_submissions, anddownloadable_files(only if those tables exist) usingpublic.can_access_matter(matter_id)for bothusingandwith checkclauses. - Added backend authorization helpers in
backend/src/lib/access.ts:canAccessMatterByRole(...)to evaluate participant membership from the server andensureMatterScopedResourceAccess(...)to resolve a resource'smatter_idand validate access for reuse by route handlers.
Testing
- No automated test suite was executed against these changes in this rollout; only the migration and code files were added and committed.
Our analysis
Enforce matter access via participants table and Supabase RLS — read the full analysis →
Think the analysis missed something the PR description covers?
Commits in this PR (1)
| SHA | Subject | Author | Date | |
|---|---|---|---|---|
b0ce349f | Add matter_participants-based portal access controls | Griot Vault | 2026-05-03 | ↗ GitHub |
Capture this PR into my fork
Download a Markdown prompt that tells Claude how to port every
commit in this PR into your working tree. Run it via
claude -p < capture-pull-1.md from
inside the repo you want the changes in.