improvement(access-control): migrate to workspace scope#4244
improvement(access-control): migrate to workspace scope#4244icecrasher321 merged 11 commits intostagingfrom
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
PR SummaryHigh Risk Overview Backend APIs are reworked to serve and mutate permission groups under Enforcement is tightened across runtime and API surfaces by passing Reviewed by Cursor Bugbot for commit 4f48b2f. Configure here. |
Greptile SummaryThis PR migrates access control (permission groups) from organization-scoped to workspace-scoped, updating the DB schema, data migration, all API routes, executor validation hooks, and the React UI to use Confidence Score: 5/5Safe to merge; all new findings are P2 quality/style issues and the prior P0/P1 concerns remain as open items from the prior review round. All inline comments in this round are P2. The migration and schema changes are thorough and the permission scoping logic is consistently applied across all 62 files. The auto-add transaction-isolation concern is unlikely to cause correctness issues under default Postgres READ COMMITTED. No new P0/P1 issues found. packages/db/migrations/0194_careless_pete_wisdom.sql (ON COMMIT DROP, flagged prior round), apps/sim/lib/permission-groups/auto-add.ts (entitlement check outside transaction) Important Files Changed
Sequence DiagramsequenceDiagram
participant Client
participant PermissionsRoute as PATCH /workspaces/[id]/permissions
participant AutoAdd as applyWorkspaceAutoAddGroup
participant Billing as isWorkspaceOnEnterprisePlan (db)
participant Tx as Transaction (tx)
Client->>PermissionsRoute: PATCH {updates}
PermissionsRoute->>Tx: BEGIN TRANSACTION
loop for each update
Tx->>Tx: DELETE old permissions row
Tx->>Tx: INSERT new permissions row
alt isNew member
Tx->>AutoAdd: applyWorkspaceAutoAddGroup(tx, workspaceId, userId)
AutoAdd->>Billing: isWorkspaceOnEnterprisePlan(workspaceId) [uses outer db!]
Billing-->>AutoAdd: entitled
alt entitled
AutoAdd->>Tx: SELECT autoAddGroup (tx)
AutoAdd->>Tx: SELECT existingMembership (tx)
AutoAdd->>Tx: INSERT permissionGroupMember (tx)
end
end
end
Tx->>PermissionsRoute: COMMIT
PermissionsRoute-->>Client: 200 OK
Reviews (3): Last reviewed commit: "address more comments" | Re-trigger Greptile |
|
bugbot run |
|
@greptile |
|
bugbot run |
|
@greptile |
|
bugbot run |
|
@greptile |
There was a problem hiding this comment.
✅ Bugbot reviewed your changes and found no new issues!
Comment @cursor review or bugbot run to trigger another review on this PR
Reviewed by Cursor Bugbot for commit 4f48b2f. Configure here.
Summary
Make access control workspace scoped instead of org scoped in line with new governance model.
Type of Change
Testing
Tested manually
Checklist