Skip to content

Commit 25cd48d

Browse files
jordan-umusuclaude
andcommitted
refactor(rbac): rename SYSTEM_ROLE_SCOPES to PRESET_ROLE_SCOPES
Rename the workspace role scope mapping to better distinguish between preset roles (seeded roles like viewer/editor/admin) and custom roles created by users. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 0b01759 commit 25cd48d

File tree

3 files changed

+9
-9
lines changed

3 files changed

+9
-9
lines changed

tests/unit/test_rbac_scopes.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
ORG_MEMBER_SCOPES,
2222
ORG_OWNER_SCOPES,
2323
ORG_ROLE_SCOPES,
24-
SYSTEM_ROLE_SCOPES,
24+
PRESET_ROLE_SCOPES,
2525
VIEWER_SCOPES,
2626
)
2727
from tracecat.contexts import ctx_scopes
@@ -195,9 +195,9 @@ def test_admin_includes_editor(self):
195195
assert EDITOR_SCOPES.issubset(ADMIN_SCOPES)
196196

197197
def test_system_role_mapping(self):
198-
assert SYSTEM_ROLE_SCOPES[WorkspaceRole.VIEWER] == VIEWER_SCOPES
199-
assert SYSTEM_ROLE_SCOPES[WorkspaceRole.EDITOR] == EDITOR_SCOPES
200-
assert SYSTEM_ROLE_SCOPES[WorkspaceRole.ADMIN] == ADMIN_SCOPES
198+
assert PRESET_ROLE_SCOPES[WorkspaceRole.VIEWER] == VIEWER_SCOPES
199+
assert PRESET_ROLE_SCOPES[WorkspaceRole.EDITOR] == EDITOR_SCOPES
200+
assert PRESET_ROLE_SCOPES[WorkspaceRole.ADMIN] == ADMIN_SCOPES
201201

202202

203203
class TestOrgRoleScopes:

tracecat/auth/credentials.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
optional_current_active_user,
3434
)
3535
from tracecat.authz.enums import OrgRole, WorkspaceRole
36-
from tracecat.authz.scopes import ORG_ROLE_SCOPES, SYSTEM_ROLE_SCOPES
36+
from tracecat.authz.scopes import ORG_ROLE_SCOPES, PRESET_ROLE_SCOPES
3737
from tracecat.authz.service import MembershipService, MembershipWithOrg
3838
from tracecat.contexts import ctx_role, ctx_scopes
3939
from tracecat.db.dependencies import AsyncDBSession
@@ -96,7 +96,7 @@ def compute_effective_scopes(role: Role) -> frozenset[str]:
9696
9797
For workspace-scoped requests:
9898
- Org OWNER/ADMIN: org-level scopes (they can access all workspaces)
99-
- Workspace members: workspace role scopes from SYSTEM_ROLE_SCOPES
99+
- Workspace members: workspace role scopes from PRESET_ROLE_SCOPES
100100
101101
Note: Group-based scopes will be added in PR 4 (RBAC Service & APIs).
102102
"""
@@ -115,7 +115,7 @@ def compute_effective_scopes(role: Role) -> frozenset[str]:
115115
# Org admins/owners already have workspace scopes via their org role
116116
# Regular members need their workspace role scopes
117117
if role.org_role not in (OrgRole.OWNER, OrgRole.ADMIN):
118-
scope_set |= SYSTEM_ROLE_SCOPES.get(role.workspace_role, set())
118+
scope_set |= PRESET_ROLE_SCOPES.get(role.workspace_role, set())
119119

120120
# Note: Group-based scopes (from group_assignment table) will be added in PR 4
121121
# via RBACService.get_group_scopes()

tracecat/authz/scopes.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,10 +83,10 @@
8383
)
8484

8585
# =============================================================================
86-
# System Role -> Scope Set Mapping
86+
# Preset Role -> Scope Set Mapping
8787
# =============================================================================
8888

89-
SYSTEM_ROLE_SCOPES: dict[WorkspaceRole, frozenset[str]] = {
89+
PRESET_ROLE_SCOPES: dict[WorkspaceRole, frozenset[str]] = {
9090
WorkspaceRole.VIEWER: VIEWER_SCOPES,
9191
WorkspaceRole.EDITOR: EDITOR_SCOPES,
9292
WorkspaceRole.ADMIN: ADMIN_SCOPES,

0 commit comments

Comments
 (0)