Repository navigation
feat: manage personal API keys with --personal - #1312
Merged
Merged
Conversation
Contributor
|
Claude finished @mbevc1's task in 1m 41s —— View job PR review:
|
The server now exposes /api/v2/user/api-keys for a user's own keys. `--personal` targets them instead of a service account's keys; it is mutually exclusive with `--service-account`, one of the two is required, and `--org` is not needed since personal keys belong to the user rather than an org. The owner selection lives in a shared apiKeyOwner so the other api-key commands can take the same flag.
Reads one of the caller's own keys from /api/v2/user/api-keys/KEY-ID, using the same --personal/--service-account selection as list.
Posts to /api/v2/user/api-keys. The help notes the server's rules for keys created with another API key: they are revoked with that key and expire no later than it.
Posts to /api/v2/user/api-keys/KEY-ID/rotate for each key. The help notes that a request made with an API key can rotate only that key and keys created with it, and cannot extend expiry past the calling key's.
Deletes /api/v2/user/api-keys/KEY-ID for each key. The confirmation prompt and success message name the keys as personal rather than pointing at a service account. The help notes that deleting a key also deletes the keys created with it, and that a request made with an API key can delete only that key and keys created with it.
The api-key commands gained a --personal flag, which the coverage test requires the audit to cover. The audit's --personal runs drop --service-account, which the two flags cannot be given together, and get, rotate and delete act on a personal key created for the run.
The rotate help said extending a personal key's expiry needs the Kosli web UI, but the profile page cannot rotate keys; it can create one, which is the way to get a key that outlives the calling key.
Cobra's one-required flag group counts --personal=false as given, so `kosli list api-keys --personal=false` passed validation with no owner and sent its request to /api/v2/service-accounts/<org>/api-keys, the empty service account segment dropped by url.JoinPath. The server would read that as a service account named "api-keys". The owner is now checked in each command's PreRunE instead of by the flag group, giving one clear error whether neither flag is given or --personal is false: "--service-account is required unless --personal is set". The two flags stay mutually exclusive.
mbevc1
force-pushed
the
20261028_feat_user_keys
branch
from
October 28, 2026 22:43
3d9722b to
bd93ed8
Compare
mbevc1
marked this pull request as ready for review
October 28, 2026 22:46
mbevc1
enabled auto-merge (squash)
October 28, 2026 22:46
AlexKantor87
approved these changes
Oct 29, 2026
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.
Adds a
--personalflag tokosli list/get/create/rotate/delete api-key, so you can manage your own personal API keys from the CLI and not only service account keys. The server endpoints were added in kosli-dev/server#7733.--personalcan't be combined with--service-account, one of the two is required, and--orgisn't needed for personal keys.Related to #925
Checklist
charts/k8s-reporter/) updated, if needed. Note: these changes live in a separate PR (not needed)