Skip to content

Commit 4fca5e5

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 6aee6b9 commit 4fca5e5

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
@@ -32,7 +32,7 @@
3232
optional_current_active_user,
3333
)
3434
from tracecat.authz.enums import OrgRole, WorkspaceRole
35-
from tracecat.authz.scopes import ORG_ROLE_SCOPES, SYSTEM_ROLE_SCOPES
35+
from tracecat.authz.scopes import ORG_ROLE_SCOPES, PRESET_ROLE_SCOPES
3636
from tracecat.authz.service import MembershipService, MembershipWithOrg
3737
from tracecat.contexts import ctx_role, ctx_scopes
3838
from tracecat.db.dependencies import AsyncDBSession
@@ -95,7 +95,7 @@ def compute_effective_scopes(role: Role) -> frozenset[str]:
9595
9696
For workspace-scoped requests:
9797
- Org OWNER/ADMIN: org-level scopes (they can access all workspaces)
98-
- Workspace members: workspace role scopes from SYSTEM_ROLE_SCOPES
98+
- Workspace members: workspace role scopes from PRESET_ROLE_SCOPES
9999
100100
Note: Group-based scopes will be added in PR 4 (RBAC Service & APIs).
101101
"""
@@ -114,7 +114,7 @@ def compute_effective_scopes(role: Role) -> frozenset[str]:
114114
# Org admins/owners already have workspace scopes via their org role
115115
# Regular members need their workspace role scopes
116116
if role.org_role not in (OrgRole.OWNER, OrgRole.ADMIN):
117-
scope_set |= SYSTEM_ROLE_SCOPES.get(role.workspace_role, set())
117+
scope_set |= PRESET_ROLE_SCOPES.get(role.workspace_role, set())
118118

119119
# Note: Group-based scopes (from group_assignment table) will be added in PR 4
120120
# 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)