Repository navigation
feat(cli): campus audit keys new --role — mint a key by named role - #68
Merged
Merged
Conversation
added 2 commits
October 21, 2026 06:21
The audit service has a named role catalogue for API keys (campus#918, campus PR #935): a role name is accepted wherever a scope list is accepted, and resolves to exactly one scope list. `campus audit keys new` still took a raw --scope list, so the operator assembling scopes by hand is exactly what the catalogue exists to remove. --role now names one of the service's roles (traces-viewer, traces-searcher, traces-producer, key-operator), and --scope and --role are mutually exclusive — the service refuses both together, because it leaves it ambiguous which was meant, so the CLI refuses them first rather than sending a request that will be rejected. The catalogue is the service's, not the CLI's: the CLI passes the name through and lets the service refuse an unknown role with the names of the roles it does have. The CLI keeps no copy that could drift. `campus audit keys update --role` re-scopes a key the same way, and the dry-run output shows the role it would send.
Picks up campus-api-python#113, which adds the `role` parameter to the audit apikeys resource — the one this branch's `--role` flag depends on. Same shape as #52 (relock campus-python for the grants resource).
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.
Closes #67
Summary
The audit service has a named role catalogue for API keys (campus#918, campus PR #935): a role name is accepted wherever a scope list is accepted, and resolves to exactly one scope list.
traces-viewertraces:readtraces-searchertraces:read,traces:searchtraces-producertraces:read,traces:search,traces:writekey-operatorapikeys:read,apikeys:writecampus audit keys newstill took a raw--scopelist, so the operator assembling scopes by hand was exactly what the catalogue exists to remove. Now:The rules the CLI mirrors
--roleand--scopeare mutually exclusive. The service refuses both together — it leaves it ambiguous which was meant — so the CLI refuses them first rather than sending a request that will be rejected.campus audit keys newwith neither now fails with a clear message rather than sending an empty privilege set.The relock
The second commit relocks
campus-pythonto pick up campus-api-python#113, which adds theroleparameter to the SDK'sapikeysresource — the one this flag depends on. Same shape as #52 (relock campus-python for the grants resource).The lock moves
campus-api-pythonfromdad0442to2667846, and the installed SDK'sAPIKeys.new()andAPIKey.update()now both carryrole.Testing
Six new cases in
tests/unit/test_audit.py(TestKeysRole): the role is forwarded with no scope list;--scopestill works and forwards no role; role and scope together are refused before any request is made; neither is refused;keys updateaccepts a role;keys updaterefuses role and scope together.poetry run pytest: 302 passed.ruff check .clean.Related