improvement(governance): org-ws-credential roles clarity#5134
improvement(governance): org-ws-credential roles clarity#5134icecrasher321 wants to merge 3 commits into
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
PR SummaryHigh Risk Overview Backend enforcement adds Product guardrails: PATCH workspace permissions rejects changing org owner/admin roles; org roster shows org admins as admin on all org workspaces. Member and credential UIs disable role changes for inherited roles and show Tests cover credential actor context, org-admin workspace access, and accessible workspace listing elevation. Reviewed by Cursor Bugbot for commit fc753a8. Configure here. |
Greptile SummaryThis PR implements a role-inheritance governance model: org owners/admins are derived workspace admins, and workspace admins are derived credential admins. It centralises the resolution logic in a new
Confidence Score: 4/5Safe to merge with one fix: the last-admin guard in the credential member DELETE endpoint should account for derived workspace admins before blocking removal. The governance model and shared resolver are well-structured. One functional regression was found: the credential member DELETE handler's 'last explicit admin' guard was not updated to account for the new model where workspace admins are derived credential admins but no longer receive explicit admin rows at credential-creation time. This means the last explicit credential admin (typically the creator) cannot be removed even when workspace-derived admins still have full access, creating a permanently stuck state. apps/sim/app/api/credentials/[id]/members/route.ts — the Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
OrgOwner([Org Owner])
OrgAdmin([Org Admin])
WsOwner([Workspace Owner])
WsAdmin([Workspace Admin - explicit])
WsMember([Workspace Member])
OrgOwner -- "derived workspace admin" --> WsAdmin
OrgAdmin -- "derived workspace admin" --> WsAdmin
WsOwner -- "implicit workspace admin" --> WsAdmin
WsAdmin -- "derived credential admin\n(shared creds only)" --> CredAdmin([Credential Admin])
WsMember -- "explicit credential member\n(via credentialMember table)" --> CredMember([Credential Member])
CredAdmin --> CanManage[Can manage credential\n & its members]
CredMember --> CanUse[Can use credential]
style OrgOwner fill:#d4edda
style OrgAdmin fill:#d4edda
style WsAdmin fill:#cce5ff
style CredAdmin fill:#fff3cd
%%{init: {'theme': 'base', 'themeVariables': {"darkMode": true, "background": "#0d1117", "primaryColor": "#21262d", "primaryTextColor": "#e6edf3", "primaryBorderColor": "#8b949e", "lineColor": "#8b949e", "textColor": "#e6edf3", "edgeLabelBackground": "#161b22", "actorBkg": "#21262d", "actorBorder": "#8b949e", "actorTextColor": "#e6edf3", "actorLineColor": "#8b949e", "signalColor": "#8b949e", "signalTextColor": "#e6edf3", "noteBkgColor": "#373320", "noteBorderColor": "#d4a72c", "noteTextColor": "#f0e6c0", "labelBoxBkgColor": "#21262d", "labelBoxBorderColor": "#8b949e", "labelTextColor": "#e6edf3", "loopTextColor": "#e6edf3", "activationBkgColor": "#30363d", "activationBorderColor": "#8b949e"}}}%%
flowchart TD
OrgOwner([Org Owner])
OrgAdmin([Org Admin])
WsOwner([Workspace Owner])
WsAdmin([Workspace Admin - explicit])
WsMember([Workspace Member])
OrgOwner -- "derived workspace admin" --> WsAdmin
OrgAdmin -- "derived workspace admin" --> WsAdmin
WsOwner -- "implicit workspace admin" --> WsAdmin
WsAdmin -- "derived credential admin\n(shared creds only)" --> CredAdmin([Credential Admin])
WsMember -- "explicit credential member\n(via credentialMember table)" --> CredMember([Credential Member])
CredAdmin --> CanManage[Can manage credential\n & its members]
CredMember --> CanUse[Can use credential]
style OrgOwner fill:#d4edda
style OrgAdmin fill:#d4edda
style WsAdmin fill:#cce5ff
style CredAdmin fill:#fff3cd
|
|
@greptile |
|
bugbot run |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 3ab3a0c. Configure here.
| return NextResponse.json({ error: 'userId query parameter required' }, { status: 400 }) | ||
| } | ||
|
|
||
| const admin = await requireWorkspaceAdminMembership(credentialId, session.user.id) |
There was a problem hiding this comment.
Last admin ignores derived admins
Medium Severity
Demote and remove handlers still treat only explicit credential_member rows with role admin as admins. New credentials no longer seed workspace admins as explicit admins, so demoting or removing the last explicit admin can fail with “last admin” errors even when workspace admins still have derived credential admin access.
Additional Locations (1)
Reviewed by Cursor Bugbot for commit 3ab3a0c. Configure here.


Summary
Org Admins are auto Workspace Admins. And workspace admins are auto credential admins.
Type of Change
Testing
Tested manually
Checklist