fix(auth): allow API keys to manage workspace tables#2762
Open
mcm wants to merge 1 commit into
Open
Conversation
/tables/* routes were declared with WorkspaceUserRouteRole, which sets
allow_api_key=False — service accounts were 403'd before scope checks
ran. The table:* scopes weren't in the service-account assignable
allowlist either, so this opens both halves.
- Swap WorkspaceUserRouteRole -> WorkspaceActorRouteRole on all table
endpoints
- Add table:{read,create,update,delete} to
WORKSPACE_SERVICE_ACCOUNT_ASSIGNABLE_SCOPES
- Update parametrized assignability tests to match
Follows the pattern in TracecatHQ#2759.
|
✅ No security or compliance issues detected. Reviewed everything up to 33a2653. Security Overview
Detected Code Changes
|
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.
Problem
Every endpoint in
tracecat/tables/router.pywas declared withWorkspaceUserRouteRole, which setsallow_api_key=False. Service-account API keys were therefore rejected with 403 before the per-endpointrequire_scope(...)check ever ran, regardless of whichtable:*scopes the key actually held.On top of that — and what makes this PR broader than the recent siblings — the
table:*scopes were never added to the service-account assignable allowlist (WORKSPACE_SERVICE_ACCOUNT_ASSIGNABLE_SCOPES). So even after flipping the dependency, admins couldn't actually grant table access to an API key. This PR opens both halves.Changes
tracecat/tables/router.py— swapWorkspaceUserRouteRole→WorkspaceActorRouteRoleon all 18 endpoints (and the import).Actoris a superset ofUser, so user-session callers see no behavior change.tracecat/service_accounts/constants.py— addtable:read,table:create,table:update,table:deletetoWORKSPACE_SERVICE_ACCOUNT_ASSIGNABLE_SCOPES.ORG_SERVICE_ACCOUNT_ASSIGNABLE_SCOPESpicks them up via union, no separate edit. The scopes themselves are already defined intracecat/authz/scopes.py(present in the VIEWER / EDITOR / ADMIN preset sets).tests/unit/test_service_accounts_validation.py—table:readandtable:createmove from the workspace "rejects user-only" parametrize list into the "allows supported API-key" list, alongside the newtable:update/table:delete. Same shuffle on the org-variant lists.Compatibility
ActoracceptsUsercallers the same asUserdoes.table:*. Admins must explicitly grant them, same as any other scope.Precedent
Follows the same route-role-swap pattern as #2759 (workspace variables and case attachments). This one is the broadest of the recent series because it adds entirely new entries to the service-account assignable allowlist, rather than just flipping a dependency on routes whose scopes were already assignable.
Test plan
ruff checkclean on changed filesruff format --diffclean on changed filesbasedpyright --warningsreports 0 errors / 0 warnings on changed filesSummary by cubic
Allow service-account API keys to manage workspace tables by enabling API-key access on tables routes and making
table:*scopes assignable. User sessions are unchanged; admins can now granttable:read|create|update|deleteto service accounts.WorkspaceUserRouteRole→WorkspaceActorRouteRoleon all/tablesendpoints so API keys aren’t rejected before scope checks.table:read,table:create,table:update,table:deletetoWORKSPACE_SERVICE_ACCOUNT_ASSIGNABLE_SCOPES(org allowlist picks them up via union).Written for commit 33a2653. Summary will update on new commits. Review in cubic