Skip to content

Commit 4bbdaf1

Browse files
committed
refactor(rbac): simplify action scopes
1 parent 2db0a31 commit 4bbdaf1

File tree

3 files changed

+9
-10
lines changed

3 files changed

+9
-10
lines changed

alembic/versions/55c5d2499eee_add_rbac_tables.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323

2424
def upgrade() -> None:
2525
# ### commands auto generated by Alembic - please adjust! ###
26-
sa.Enum("SYSTEM", "REGISTRY", "CUSTOM", name="scopesource").create(op.get_bind())
26+
sa.Enum("PLATFORM", "CUSTOM", name="scopesource").create(op.get_bind())
2727
op.create_table(
2828
"group",
2929
sa.Column("id", sa.UUID(), nullable=False),
@@ -116,7 +116,7 @@ def upgrade() -> None:
116116
sa.Column(
117117
"source",
118118
postgresql.ENUM(
119-
"SYSTEM", "REGISTRY", "CUSTOM", name="scopesource", create_type=False
119+
"PLATFORM", "CUSTOM", name="scopesource", create_type=False
120120
),
121121
nullable=False,
122122
),
@@ -400,5 +400,5 @@ def downgrade() -> None:
400400
op.drop_index(op.f("ix_group_organization_id"), table_name="group")
401401
op.drop_index(op.f("ix_group_name"), table_name="group")
402402
op.drop_table("group")
403-
sa.Enum("SYSTEM", "REGISTRY", "CUSTOM", name="scopesource").drop(op.get_bind())
403+
sa.Enum("PLATFORM", "CUSTOM", name="scopesource").drop(op.get_bind())
404404
# ### end Alembic commands ###

tracecat/authz/enums.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,10 @@ class WorkspaceRole(StrEnum):
1414

1515

1616
class ScopeSource(StrEnum):
17-
"""Source of a scope definition."""
17+
"""Source/ownership of a scope definition."""
1818

19-
SYSTEM = "system" # Built-in platform scopes (org/workspace/resources/RBAC admin)
20-
REGISTRY = "registry" # Derived from registry actions
21-
CUSTOM = "custom" # User-created scopes
19+
PLATFORM = "platform" # Platform-owned: core permissions + registry-derived
20+
CUSTOM = "custom" # Organization-defined scopes
2221

2322

2423
class OrgRole(StrEnum):

tracecat/db/models.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3144,9 +3144,9 @@ class Scope(Base, TimestampMixin):
31443144
Examples: workflow:read, org:member:invite, action:tools.okta.list_users:execute
31453145
31463146
Scopes can be:
3147-
- System scopes (organization_id=NULL): Built-in platform scopes shared across all orgs
3148-
- Registry scopes (organization_id=NULL): Auto-generated from registry actions
3149-
- Custom scopes (organization_id=org_id): User-defined scopes for an organization
3147+
- Platform scopes (organization_id=NULL): Platform-owned scopes shared across all orgs.
3148+
Use `source_ref` for provenance (e.g., "core", "tracecat_registry", git URL).
3149+
- Custom scopes (organization_id=org_id): Organization-defined scopes.
31503150
"""
31513151

31523152
__tablename__ = "scope"

0 commit comments

Comments
 (0)