feat(tokens): add admin bypass for POST /tokens/teams/{team_id} to support service account workflows#4488
Open
bogdanmariusc10 wants to merge 4 commits intomainfrom
Conversation
…rvice account workflows Resolves #4390 Problem: - POST /tokens/teams/{team_id} blocked admin tokens from creating team tokens when the admin/service account was not an active member of the target team - Prevented centralized token management by admin accounts - Inconsistent with admin model where other endpoints allow un-narrowed admins to bypass team restrictions Solution: - Added admin bypass logic in token_catalog_service.py create_token() method - Un-narrowed platform admins (caller_permissions=['*']) can now create team tokens without being active team members - Narrowed admin sessions and regular users still require team membership Security Invariants Maintained: - Requires un-narrowed platform admin (caller_permissions=['*']) - Narrowed admin sessions still require team membership - Regular users still require team membership - Team existence validation still enforced for all users - Management Plane isolation preserved - Audit trail maintained Testing: - Added 5 comprehensive tests covering admin bypass scenarios - All 137 existing token catalog service tests pass - All 77 router tests pass - All security tests pass - No new mypy or ruff errors introduced Signed-off-by: Bogdan-Marius-Catanus <[email protected]>
Signed-off-by: Bogdan-Marius-Catanus <[email protected]>
Signed-off-by: Bogdan-Marius-Catanus <[email protected]>
…steamsteam_id-to-support-service-account-workflows
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.
🔗 Related Issue
Closes #4390
📝 Summary
Adds admin bypass capability to
POST /tokens/teams/{team_id}endpoint to support service account workflows and centralized token management.Problem:
Solution:
token_catalog_service.pyto check for un-narrowed platform admin status (caller_permissions=["*"]) before enforcing team membershipUse Cases Enabled:
🏷️ Type of Change
🧪 Verification
make lintmake testmake coverageNew Tests Added:
test_create_token_admin_bypass_with_unrestricted_permissions- Verifies admin bypass works correctlytest_create_token_narrowed_admin_requires_membership- Ensures narrowed admins still need membershiptest_create_token_no_caller_permissions_requires_membership- Validates None permissions require membershiptest_create_token_empty_caller_permissions_requires_membership- Validates empty list requires membershiptest_create_token_admin_bypass_still_validates_team_exists- Ensures team existence check remains enforced✅ Checklist
make black isort pre-commit)📓 Notes
Security Invariants Maintained:
is_admin=trueANDcaller_permissions=["*"])Implementation Details:
is_unrestricted_admin = caller_permissions is not None and caller_permissions == ["*"]Testing Coverage:
["*"]permissions can create team tokensNonepermissions, users with[]permissions all require membership