Add API key management commands#169
Conversation
|
Review the following changes in direct dependencies. Learn more about Socket for GitHub.
|
|
Firetiger deploy monitoring skipped This PR didn't match the auto-monitor filter configured on your GitHub connection:
Reason: This PR adds CLI commands for API key management and does not modify the kernel API endpoints (packages/api/cmd/api/) or Temporal workflows (packages/api/lib/temporal) specified in the filter. To monitor this PR anyway, reply with |
69c0083 to
6c9deba
Compare
|
Production smoke against Auth used an org-wide production API key via Coverage run:
Org-wide key flow:
Project-scoped key flow:
Validation / edge cases:
Cleanup:
|
hiroTamada
left a comment
There was a problem hiding this comment.
lgtm — clean api-keys CLI surface, SDK bump compat shim is correct, output validator centralization checks out. minor nits (no "Created API key: " success line on create, update prints full details table where peer commands don't, kernel.Int vs kernel.Opt picks the browsers dialect over the credentials dialect) — non-blocking.
|
fixed created api key consistency. will add a pr later to normalize cli |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 689378a. Configure here.

Summary
Adds first-class programmatic API key management to the Kernel CLI using
github.com/kernel/kernel-go-sdkv0.58.0, which exposes the generatedclient.APIKeyssurface.This PR also normalizes the repeated JSON output plumbing across CLI commands so the new API key commands use the same small helper path as the rest of the CLI instead of adding another copy of the same
--output jsonvalidation pattern.What changed
API key CLI commands
Adds a new top-level
api-keyscommand with aliasesapi-key,apikeys, andapikey.New subcommands:
kernel api-keys create--nameas required input--days-to-expirefor optional expiry, validated to1..3650--project-idto create a key whose own access is scoped to a project-o json/--output jsonkernel api-keys list--limitand--offset--output jsonkernel api-keys get <id>kernel api-keys update <id>--namekernel api-keys delete <id>-y/--yesto skip confirmationSDK bump
github.com/kernel/kernel-go-sdkfromv0.53.0tov0.58.0.ManagedAuthCanReauthReason, which is now a named SDK type.Output helper normalization
Adds shared helpers for the repeated
--output jsoncommand behavior:pkg/util.ValidateJSONOutputpkg/util.AddJSONOutputFlagcmdandcmd/proxiesThen applies those helpers across existing commands that already had the same JSON-only output contract:
Why: the CLI had many copies of the same validation branch and flag description. Centralizing the behavior makes the new API-key command cheaper to review and keeps future commands from drifting on error text or flag help.
Shared flag/test helpers
BoolFlagandInt64Flagintocmd/flag_values.goso generic flag-state types are no longer accidentally owned bycmd/browsers.go.capturePtermOutputincmd/test_helpers_test.goand reuses it in touched tests for projects, profiles, extensions, and API keys.Docs
Updates
README.mdto document:--project-idon API-key creation and the global--projectrequest-scoping flagWhy
Programmatic API key CRUD now exists in the generated SDKs. The CLI needs the same capability so users can create, inspect, rotate/rename, and delete API keys without going through the dashboard.
The implementation intentionally stays direct instead of introducing a generic CRUD framework:
APIKeysServiceis a small test seam over the generated SDK surfaceProjectIDfield rather than reading SDK extra fieldsThe normalization pieces were included because API-key commands need the same JSON-only output behavior that already existed throughout the CLI. Pulling that behavior into shared helpers avoids adding another local copy and makes the surrounding CLI more consistent.
Verification
make testgo vet ./...go test ./...make buildpython3 /Users/ilyaas/.codex/skills/autoreview/scripts/autoreview --mode branch --base origin/mainautoreview clean: no accepted/actionable findings reportedI also smoke-tested the API-key flow locally against the test API earlier in the branch work:
Notes for reviewers
--project-idonapi-keys createscopes the new key itself.--projectscopes the CLI request being made.IsProjectScoped; scope display is derived from typedProjectIDinstead.Note
Medium Risk
New credential lifecycle commands and SDK bump touch auth-related surfaces; broad
--outputrefactor is mostly mechanical but wide in scope.Overview
Adds
kernel api-keys(create, list, get, update, delete) backed bykernel-go-sdkv0.58.0, including optional expiry,--project-idfor project-scoped keys (distinct from global--project), human tables plus--output json, and showing the one-time plaintext key on create.Centralizes JSON-only
--outputhandling viapkg/utilhelpers and applies them across many existing commands; movesBoolFlag/Int64Flagtoflag_values.goand sharescapturePtermOutputin tests. README documents API key commands; auth-connection display castsCanReauthReasonfor the SDK type change.Reviewed by Cursor Bugbot for commit 689378a. Bugbot is set up for automated code reviews on this repo. Configure here.