Skip to content

typetorch keys create / list / revoke: API keys with roles - #42

Merged
phasenull merged 1 commit into
mainfrom
feat/api-keys-rbac
Nov 11, 2026
Merged

phasenull merged 1 commit into
mainfrom
feat/api-keys-rbac

Conversation

@phasenull

Copy link
Copy Markdown
Member

Plan: /home/phasenull/projects/TypeTorch/plans/31-api-keys-rbac.md (CLI half). Named API keys with roles on the TypeTorch backend, managed with the admin token.

Commands

  • typetorch keys create --name <name> --role <game|lookup|support|analyst|admin> [--expires 365d|90d|1y]: POST /v1/admin/keys.
    • Prints the key once, with a "store it now, it is not shown again" line; --json returns it in key.
    • Registered with the redaction list as soon as it arrives; never written to disk or logs.
    • No error message quotes a reply body that held a key.
  • typetorch keys list [--all]: GET /v1/admin/keys[?all=1]. A table of id, name, role, scopes, expires, last used, state (active / built-in / revoked); --json too.
  • typetorch keys revoke <id>: DELETE /v1/admin/keys/{id}. Refused locally, before any request:
    • built-in env:* ids, with a hint to rotate the env variable instead;
    • a pasted whole key: it is scrubbed, and the user is told to treat it as exposed.
  • Validation: name [a-z0-9._-]{1,48}, the five roles, expiry 1..3650 days.
  • These share the keys command with the prod-signing subcommands (init, rotate, resign), which are unchanged. API-key flags are refused on those.

Test plan

  • bunx tsc --noEmit
  • bun test test/apikeys.test.ts: 16 pass. Covers:
    • each command's request against a mocked backend;
    • validation;
    • the key appears exactly once in plain and --json output, and never in errors or in list / revoke output;
    • built-ins and whole keys refused for revoke.
  • full bun test: 875 pass, 1 fail. The failure is the known backend bless full-run test, which also fails on main.
  • bun run build, node scripts/smoke.mjs
  • After the backend PR on feat/api-keys-rbac is deployed: typetorch keys create/list/revoke against a test backend.

No version bump.

🤖 Generated with Claude Code

…he backend

- create: POST /v1/admin/keys { name, role, expiresDays? }; the key printed once (--json: in key), registered with
  the scrubber the moment it arrives, never written anywhere; no error quotes a reply that held a key
- list [--all]: id, name, role, scopes, expires, last used, built-in / revoked
- revoke <id>: DELETE /v1/admin/keys/{id}; built-in env:* ids and pasted whole keys refused locally
- validation: name [a-z0-9._-]{1,48}, the five roles, --expires 1-3650 days (90d, 365d, 1y)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@phasenull
phasenull merged commit 896d4df into main Nov 11, 2026
1 check passed
@phasenull
phasenull deleted the feat/api-keys-rbac branch November 11, 2026 13:41
@phasenull
phasenull restored the feat/api-keys-rbac branch November 27, 2026 19:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant