feat(rbac): accept service-account actors and make org:rbac:* assignable#2810
Open
mcm wants to merge 1 commit into
Open
feat(rbac): accept service-account actors and make org:rbac:* assignable#2810mcm wants to merge 1 commit into
mcm wants to merge 1 commit into
Conversation
The org RBAC routers (OSS user-assignments/roles and the EE
scopes/roles/groups/assignments routers) gated every endpoint on
OrgUserRole, whose RoleACL sets allow_api_key=False. That made the
entire RBAC surface unreachable by service-account API keys even when
the key held the required org:rbac:* scope — the ACL rejected the
principal before require_scope ran.
Two coupled gaps blocked service-account access:
- ACL: every RBAC endpoint used OrgUserRole. Switch to OrgActorRole
(allow_api_key=True) so users AND service accounts are admitted; the
existing @require_scope("org:rbac:*") decorator remains the real gate.
Also widen the EE _require_rbac_entitlement router dependency.
- Assignability: org:rbac:* was absent from
ORG_SERVICE_ACCOUNT_ASSIGNABLE_SCOPES, so the scope could never be
granted to a service account in the first place. Add read/create/
update/delete.
Unblocks the portal's membership-sync principal, which calls
GET/PATCH /rbac/user-assignments with a service-account key.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Checklist
uv run pytest tests)?pre-commit run --all-files)?Description
The portal's workspace membership-sync principal (a Tracecat service account / API key) calls
GETandPATCH /rbac/user-assignmentsto mirror the Default Workspace's user→role assignments into every tenant workspace. Both calls fail today for two coupled reasons:ACL rejects service accounts. Every org RBAC endpoint — OSS
user-assignments+roles, and the EEscopes/roles/groups/assignmentsrouters — gated onOrgUserRole, whoseRoleACLsetsallow_api_key=False. A service-account key is rejected at the dependency layer before@require_scopeever runs, regardless of the scopes it holds.org:rbac:*was never assignable to a service account.org:rbac:read/create/update/deletewas absent fromORG_SERVICE_ACCOUNT_ASSIGNABLE_SCOPES, so the scope could not be granted to a service account in the first place.Changes
OrgUserRole→OrgActorRole(allow_api_key=True) on all org RBAC endpoints intracecat/authz/rbac/router.pyandtracecat_ee/rbac/router.py, including the EE_require_rbac_entitlementrouter dependency.@require_scope("org:rbac:*")remains the real authorization gate — this only widens the who (user or service account), not the what.org:rbac:read/create/update/deletetoORG_SERVICE_ACCOUNT_ASSIGNABLE_SCOPESso the scopes can actually be granted to a service account._resolve_assignable_scopesstill prevents privilege escalation (a caller can only grant scopes it already holds).test_service_accounts_validation.py:org:rbac:*now asserted assignable to org service accounts.get_my_scopes(/users/me/scopes) is intentionally left user-only — it is an identity endpoint, not an RBAC-management one.🤖 Generated with Claude Code
Summary by cubic
Enable service-account API keys to access org RBAC endpoints by accepting service-account actors and making
org:rbac:*scopes assignable. This unblocks the membership-sync service account to mirror user→role assignments viaGET/PATCH /rbac/user-assignments.New Features
OrgUserRoletoOrgActorRoleacross OSS and EE RBAC routers (incl. entitlement check) so users and service accounts pass ACL;@require_scope("org:rbac:*")remains the gate.org:rbac:read,org:rbac:create,org:rbac:update,org:rbac:deletetoORG_SERVICE_ACCOUNT_ASSIGNABLE_SCOPES; callers can only grant scopes they hold.org:rbac:*is assignable to org service accounts;get_my_scopesstays user-only.Migration
org:rbac:*scopes to service accounts that manage org RBAC (e.g., the membership-sync key).Written for commit 33c1ba4. Summary will update on new commits.