Skip to content

Decision: should a block on a member's personal API key also stop the keys they make next? #5404

Open

Description

@yannickmonney

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:251 writes one row keyed by (org_id, api_key_id) (app.api_key_org_blocks, migration 0231_api_key_org_blocks.sql).
  • services/platform/backend/rest/v1.ts:485-496 refuses a request with API_KEY_BLOCKED only 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

Options (no preference)

  1. 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.
  2. 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.
  3. 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.
  4. Keep it as documented. To cut a person off here, an admin disables or removes the member.

Questions

Related

#5397, #5217, #5218

Activity

  1. added
    priority: medium
    needs discussion
    service: platform
    on Nov 6, 2026
  2. yannickmonney commented on Nov 14, 2026

    @yannickmonney
    ContributorAuthor

    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:

    • M's personal keys that work everywhere, including any M makes after the block;
    • M's own keys bound to A after a single sign-on sign-in (APIKEY-R13).

    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/block stays 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

    1. Holder block in the backend and the spec (train, L): migration and backfill, door check with a dual-table read, creation refusal, routes, audit and bell, spec rewrites.
    2. UI, locales, docs, manual box (train, M).
    3. Reconcile with the feat(platform): let an organization refuse members' personal API keys #5218 switch on the feature line (feature-train, M), after the rebase brings units 1 and 2.
    4. Drop the per-key table and the alias (feature-train, S, for 0.6.0), running the backfill again first.

    Cross-issue amendments (decisions taken together with #5406, #5046, #5218):

  3. added
    agent-ready
    and removed
    needs discussion
    on Nov 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    agent-readypriority: mediumservice: platform

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions