Skip to content

Self-service API keys: org-admin minting with a role ceiling, list endpoint, show-once UI #866

Done

Description

@athvin

API product implementation work · roadmap #1008 · use parent dependency order; not a separate product rank.

Part of #857. Stack rank 9 of 13. Depends on: T1 (the ApiKeyWire struct is what makes the list endpoint unable to leak key_hash). Runs in parallel with T2–T4.

Color

Today "a user sets up their own connection" is: ask the operator. create_key is operator-only (operator_only(&principal), not an org guard), there is no GET list endpoint at all (only POST + DELETE are routed), and no frontend surface mentions API keys anywhere. This is the product half of the epic — a customer admin mints a key, sees the plaintext once, and connects — and it is what the docs surface (T10) documents as the getting-started flow.

Scope

Backend (er-server):

  • create_key drops operator_only for guard(&principal, &org, Role::Admin) with a role ceiling: a minted key's role ≤ the minter's (operator already unmintable via parse_key_role). The operator path keeps working — operator passes any org guard.
  • New GET /v1/orgs/{org}/api-keys (Admin) returning ApiKeyWire rows — id, role, created_at, revoked_at; never key_hash, enforced by T1's wire struct rather than by care.
  • revoke_key gets the same admin path.
  • Doc comments in the house Role: summary (`METHOD /path`) shape — the manifest, envelope and OpenAPI gates all regenerate from them, so the new route fails CI until described.
  • Audit: key.issue/key.revoke already write audit rows — extend assertions, don't rebuild.

Frontend:

  • BFF routes under src/app/api/orgs/[org]/api-keys/… with authz entries (check-bff-authz.mjs fails without them).
  • Settings page cloning the webhook show-once pattern (webhooks-content.tsx:254 renders created.secret exactly once): mint → plaintext displayed once with a copy affordance → list shows metadata only → revoke. Grayscale per the design system; registered in the axe gate.

Skills in this PR: er-server-control-plane (minting rules change), frontend-bff (new routes).

Out of scope

Key rotation, expiry, scoped/limited keys — file follow-ups if wanted. The docs page itself (T10).

Testing

pg_auth.rs harness (one test per pg_*.rs file, sequential phases):

  • Admin mints for own org → 201 with plaintext.
  • Admin cannot mint for another org → 404 (the cross-org rule — not 403).
  • Steward/viewer cannot mint → 403.
  • Ceiling: admin cannot mint operator → 422 (already enforced; keep the regression).
  • Plaintext appears in exactly one response and never again; the list returns no hash and no plaintext.
  • Audit rows for issue + revoke asserted.

Frontend: component tests for the show-once flow; Playwright functional path (mint → copy → list → revoke) against the mock; make frontend.

Definition of done

Epic DoD, plus: a fresh org's admin can mint → copy → successfully call GET /v1/orgs/{org} with the new key, and that flow is written down as the getting-started content T10 publishes.

Activity

  1. added
    enhancement
    rust
    javascript
    mvp
    on Nov 8, 2026
  2. self-assigned this
    on Nov 25, 2026
  3. athvin commented on Nov 25, 2026

    @athvin
    OwnerAuthor

    Claimed — working in the draft PR linked above (closing it releases the claim).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

enhancementjavascriptmvprust

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions