Repository navigation
Description
Summary
From v0.5.102 (#5397) an Owner or Admin can block a member's personal API key in one organization. The block names one key. The holder can create another personal key at once, and that key works in the organization: nothing blocks it, and no Owner or Admin is told. The feature line closes the same gap with an organization-wide switch for members' personal keys (#5218), which the stable port left out on purpose.
The behaviour is documented, not hidden: services/platform/backend/domains/api_keys/spec.md:214-215 lists it under "Not yet", and docs/en/platform/admin/api-keys.md:88 says a block "does not cover a new key the member creates for themselves, which has to be blocked too".
What the code does
At 80ca60f07 on train, which lands on main with the v0.5.102 train:
services/platform/backend/domains/api_keys/blocks.ts:251writes one row keyed by(org_id, api_key_id)(app.api_key_org_blocks, migration0231_api_key_org_blocks.sql).services/platform/backend/rest/v1.ts:485-496refuses a request withAPI_KEY_BLOCKEDonly when that exact key id has a row for the resolved organization.- Creating a personal key (
POST /api/auth/api-key/create) does not read the holder's blocks.
Observed
Local stack at the train's head, 2026-11-06. The test data was synthetic: two organizations, an Owner, and a Developer who belongs to both.
| Step | Result |
|---|---|
| The Owner blocks the Developer's personal key in organization A. | That key: 403 API_KEY_BLOCKED in A, 200 in B. |
| The Developer creates a new personal key. | The new key: 200 in A at once. |
| The Owner's notifications | Nothing about the new key. |
| The Owner's All keys in this organization | Lists the new key as an ordinary personal key. The blocked key is left out of this view, as designed. |
| The Owner's Personal API keys dialog for the Developer | Shows the old key Blocked here and the new one Works here. |
Not examined: how often holders do this in practice.
Constraints
- A personal key works in every organization its holder belongs to. One organization's decision must not reach the holder's other organizations (APIKEY-R11).
- feat(platform): bring #5217 to the stable line — an Admin can block a member's personal API key in their organization #5397 asks for the acceptance requirement that administrators can revoke the personal access tokens reaching their organization.
Options (no preference)
- Port feat(platform): let an organization refuse members' personal API keys #5218 to the stable line: an organization can refuse every member's personal keys, the way the feature line does.
- Block the holder rather than the key: a block in an organization covers every personal key of that person there, including keys made later, until it is lifted.
- Keep per-key blocks, and tell the organization's Owners and Admins when a member with a blocked key here creates a new personal key.
- Keep it as documented. To cut a person off here, an admin disables or removes the member.
Questions
- Does the acceptance requirement in feat(platform): bring #5217 to the stable line — an Admin can block a member's personal API key in their organization #5397 count a key the holder creates after the block?
- If option 2: should lifting free every key of the holder, or only the one named?
Activity
yannickmonney commentedon Nov 14, 2026
Decision
Option 2: an organization blocks the holder, not one key. When an Owner or Admin of organization A blocks member M, A refuses (403
API_KEY_BLOCKED) every key M made for themselves:While blocked, M cannot create any key in A: not their own SSO-bound key, and not a key for a member, team, project or the organization. Keys made earlier for others keep working, and whoever may end them ends them. The block never reaches M's other organizations (APIKEY-R11). It survives M leaving and rejoining A, and it is deleted with the organization or the user account. Role rules: only Owners and Admins block or lift, an Admin acts on nobody above them, nobody blocks or lifts a block on themselves, and repeats change nothing.
Existing per-key blocks are folded into holder blocks, keeping the earliest, and each affected holder gets a bell. Until the old table is dropped, the door honours a row in either table, so a block written mid-roll is never lost.
PUT/DELETE /api/app/api-keys/:keyId/blockstays as a deprecated alias. The new route is/api/app/api-keys/members/:userId/block. On the feature line, the #5218 switch is checked first, then the holder block.Answers
Rationale
A block that its target can get around with one click is not a control. A request-time block on the person covers later keys, and refusing every key creation while blocked closes the SSO-key and Admin-made-key bypasses. Keeping the block across rejoin stops an SSO rejoin from shedding it. The org-wide switch cannot single out one person, a notification only detects the bypass after the new key already works, and disabling the member also cuts off web access.
Implementation units
train, L): migration and backfill, door check with a dual-table read, creation refusal, routes, audit and bell, spec rewrites.train, M).feature-train, M), after the rebase brings units 1 and 2.feature-train, S, for 0.6.0), running the backfill again first.Cross-issue amendments (decisions taken together with #5406, #5046, #5218):