Repository navigation
feat(api): self-service API keys — admin minting with a role ceiling, list, show-once UI (#866) - #1216
Merged
Conversation
create_key and revoke_key move from operator_only to the org Admin guard,
so a customer admin connects without asking the operator. The operator
still passes every org guard. The minted role is capped at the minter's
own, and operator stays unmintable (422). A new GET /v1/orgs/{org}/api-keys
(Admin) lists the org's keys newest first, revoked included, through
ApiKeyWire, which has no key_hash field. The new api_key read by_org
statement is declared and generated.
pg_auth covers:
- admin mints in its own org (201, plaintext) and gets 404 on another
existing org
- viewer and steward get 403; operator is 422
- the minted key calls GET /v1/orgs/{org}
- the list is admin-only, 404 cross-org, and never contains a hash or a
plaintext
- admin revoke, after which the key 401s
- one key.issue and one key.revoke audit row for the key
Co-Authored-By: Claude Opus 5.5 <[email protected]>
#866) BFF routes under /api/orgs/[org]/api-keys (GET/POST) and /api-keys/[keyId] (DELETE), all requireOrgAccess(org, "admin"). The list unwraps er-server's {keys} (ledger: wrapped/keys) and marks the app's own service keys. The settings page follows the webhook secret's show-once pattern: the plaintext and a copy button appear only in the mint response's moment, with a curl line to check it works. The guard this needed: the BFF calls er-server with three per-org service keys it minted at registration, and those keys appear in the org's list. Revoking one would sign the app out of the org for every member. serviceKeyIds(org) reads org_credentials, so the list marks them 'Used by this app' and offers no revoke, and the DELETE route refuses them with a 409 that says why. Mock: a stateful per-org key store seeded on new keys-{dev,ios,android} orgs with the fixtures' service keys plus one customer key. Minted plaintexts are unique and never equal a stored service credential. Tests: api-keys.test.tsx (show-once, revoke offered only for active customer keys, non-admin notice, roles offered) and api-keys.spec.ts (mint, copy, list without plaintext, revoke, reload; 409 on a service key; 403 for a viewer). The page is registered in the axe sweep. The developer reference is regenerated (the key routes are public now). Co-Authored-By: Claude Opus 5.5 <[email protected]>
…efs (#866) er-mcp: the /api-keys routes are admin tools in the regenerated manifest, and offered() now excludes them. A prompt-injected agent holding an admin key could otherwise mint a durable credential and leak it beyond the session it was trusted for. Pinned by credential_management_is_never_offered. Skills: - er-server-control-plane: minting is org Admin with a role ceiling, plus the list endpoint and the MCP exclusion. - frontend-bff: the app's own service keys are guarded at the BFF. - Regenerated references: the entities index, plus the screens and dense surfaces lists for the new page. The api-keys spec's non-admin case logs in as the steward. The viewer is not a member of the per-project orgs, so it never reached the page. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ab (#866) The settings nav gains an eighth tab, which reflows its rows on narrow viewports (settings-nav.tsx warns of exactly this). Regenerated with scripts/frontend-dev/update-baselines.sh in the pinned image. Only the three config-studio shots carry the settings nav. The script's other 21 rewrites were sub-tolerance noise on screens this change does not touch, and are left out to keep the diff to what moved. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
…tement (#866) catalog_bounds_match_declared_sql_and_distinct_relations pins the er.statement attribute's cardinality to the number of declared .sql files. by_org is the 280th. Co-Authored-By: Claude Opus 5.5 <[email protected]>
athvin
marked this pull request as ready for review
November 25, 2026 07:53
12 tasks done
Contributor
|
The marketing preview was removed because this PR is closed or merged. |
The OpenAPI documents were regenerated with the new GET
/v1/orgs/{org}/api-keys, but the TypeScript types were not, so the
frontend gate's regenerate-and-diff step failed.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
athvin
temporarily deployed
to
marketing-preview
November 25, 2026 08:06 — with
GitHub Actions
Inactive
This was referenced Nov 25, 2026
This branch was previously deployed
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 #866
What
A customer org admin can now mint, list and revoke its own API keys, from a settings page or over the API. Before this, every key came from the operator.
create_keyandrevoke_keymove from operator-only to the org Admin guard.operatoris still never mintable (422).GET /v1/orgs/{org}/api-keys(Admin), served throughApiKeyWire, which has no hash field./api/orgs/[org]/api-keysroutes, all admin.curlcheck, list, revoke./api-keysroutes to agents.Why
#857 / #1013: "connect your own system" was a support ticket. This is the getting-started step the docs page (#867) publishes.
Proof
make check: 1,165 passed, 0 failed.make frontend: 946 passed, 0 failed (lint, format, types, authz, unit with the coverage floor, Playwright functional).pg_authagainst Postgres covers every case in the ticket:operatoris 422GET /v1/orgs/{org}key.issueand onekey.revokeaudit rowoperator_onlyon mint fails the test.er-server --testsagainst Postgres: 396 passed.api-keys.test.tsx: 5 component tests.api-keys.spec.ts: 9 Playwright runs across 3 projects (mint, copy, list, revoke, reload; 409 on a service key; 403 below admin).credential_management_is_never_offered.Risk & rollback
This widens who can mint keys: org admins, not just the operator. It's bounded by the org guard, the role ceiling, the service-key refusal and the agent exclusion. Three config-studio visual baselines change, because the settings nav gains a tab. Rollback:
git revert <merge-sha>.Post-merge ledger
Closed by: agent · session
Claude Code:d1e3b2dc-3174-4091-9c30-c08fc4820306onMac· 2026-11-25T08:27:55Zmainis green with this change on it: merge8bd3c294. The push runsrust45573448080 andfrontend45573447979, plusinfra,devcontainerandmarketing preview, all succeeded.imagesbuilt: run 45573447915, success.deployconverged: run 45573985806 succeeded withDEPLOY_SHA: 8bd3c294…. Process proof, read 2026-11-25 after SSO was renewed: the live colour in dev (ci/web-api-blue) and prod (app/web-api-green) runser-api@sha256:e935e7e5…. ECR tags that digest8bd3c294(feat(api): self-service API keys — admin minting with a role ceiling, list, show-once UI (#866) #1216's merge), which contains this merge (8bd3c294) as an ancestor, and both pods logged"er-server listening","addr":"0.0.0.0:8000"at 08:11Z.driftandkindwere already red on schedule before feat(api): typed response structs, batch 3 — reviews+merges (#1193) #1202. The nightly golden-50k flake is scale golden (50k) fails deterministically on main since 03792063..ad38be23 (likely the DuckDB 2.0.1 bump) #1206.er-server-control-planeandfrontend-bffskills (minting rules and the service-key guard), and memorytyped-responses-864(schema.d.tsdrift is checked only in CI).Specific to this change
Context — plan, discoveries, measurements, files
Plan
api_keyread by_orgstatement and generate it.list_keys, andApiKeyListonResponseDoc. The envelope ledger gainswrapped/keys.serviceKeyIds(org).keys-{dev,ios,android}orgs; component, functional and axe coverage.er-server-control-plane(minting rules),frontend-bff(the service-key guard).Discoveries
mintServiceKeys(admin.ts) mints three keys per org that the BFF calls er-server with, so a customer admin would see them and could revoke them, signing the app out of their org. They are matched byorg_credentials.key_id, then marked and refused.offered().=all. Only the three config-studio shots carry the settings nav. The other 21 were sub-tolerance noise on untouched screens and are not included.Measurements
Files
Backend:
entities/api_key/read/by_org.{sql,yaml},rust/crates/er-server/src/{lib.rs,openapi.rs},rust/crates/er-server/tests/pg_auth.rs,rust/crates/er-mcp/{src/manifest.rs,tools.json}. Frontend:src/app/api/orgs/[org]/api-keys/**,src/app/(tenant)/[org]/settings/api-keys/page.tsx,src/components/settings/api-keys-content.tsx,src/lib/query/api-keys.ts,src/lib/bff/credentials.ts, the mock and fixtures, tests.