Skip to content

Decision: should a role in one organization let a member create an API key that works in another? #5046

Open

Description

@yannickmonney

Summary

A pilot tester could create API keys in an organization where they are only a member and hold no grant. They traced it to their account being an Admin in another organization. The rule for holding a personal key is judged per person, not per organization:

  • mayCreateApiKeys (services/platform/backend/auth/api-key-create-gate.ts:52-81) admits anyone who is an Owner, Admin or Developer in any organization, or who holds a key-using grant (tale:models.api, tale:notifications.export, tale:rest.act-as) in any active seat (truth table at :20-26).
  • The key "works in every organization you belong to" (backend/domains/api_keys/spec.md:16) and acts there with the holder's role.
  • The docs present it differently. A grant "applies in this organization only", and a member gets key creation as part of a grant (docs/en/platform/admin/governance/competences.md).

So organization B's admins decide through grants who may hold a key, yet a role in organization A overrides that. B's admins also cannot see the resulting key (#5045).

The key cannot do more than the holder's role in B, because every door judges each call. B's model endpoints still need B's switch and B's grant or role (backend/domains/model_api/access.ts). What the key adds in B is programmatic REST and MCP access as that member, which B never granted.

mayConnectAgentIn (api-key-create-gate.ts:92-109), the rule for connecting a coding agent, already judges one organization at a time.

Options (not exhaustive)

  1. Judge per organization when a key is used. A personal key works in an organization only while its holder may hold a key there: an Owner, Admin or Developer role there, or a key-using grant there. Otherwise the call gets a 403 with a reason. Creating a key stays "allowed in at least one organization".
  2. Bind each personal key to the organization it is made in. The right, the listing (APIKEY-R8) and the ending then all live in one organization. This breaks anyone who uses one key across organizations, and needs a migration for existing keys.
  3. Keep the rule. Explain it in Settings › API: "You can create keys because you are an Admin in A; here the key acts as a Member."

Questions

  • Do multi-organization setups, such as separate test and production organizations, rely on one key working across organizations?
  • Under option 2, what happens to existing keys that already work in several organizations?

Done when

  • An option is chosen, and the APIKEY spec, the create gate, the key authentication and the docs agree with it.
  • Tests: a person who is an Admin in A and a Member without a grant in B cannot use a key in B (option 1), or cannot create one there (option 2).

Activity

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

    @yannickmonney
    ContributorAuthor

    Decision

    Option 1: judge each organization when a key is used. A person's own API key works in an organization only while its holder may hold a key there:

    • an Owner, Admin or Developer role in that organization, or
    • a live grant there of a capability used with a key (Call models over the API, Export notifications, Act for another member), on a seat that is not disabled.

    Otherwise the call gets 403 API_KEY_NOT_ADMITTED. The answer names the role or competence it takes and lists the organizations where the key still works.

    This is the rule that connecting a coding agent already applies (mayConnectAgentIn). It becomes the single rule mayHoldApiKeyIn. Every call is checked at the REST door, which MCP and the model endpoints share.

    What else changes:

    • Single-sign-on keys. A key a person made for themselves after a single sign-on (APIKEY-R13) is checked again on every call, so a revoked grant stops it at the next call.
    • Unchanged keys. Keys an Owner or Admin made for a member (APIKEY-R2), and team, project and organization keys, work as before.
    • Creating a key. A person may still create a key if they are admitted in at least one organization, because a key belongs to its person. Settings › API offers Create only in an organization where the key would work. Elsewhere it explains why and where the key does work.
    • New rule. This becomes spec rule APIKEY-R14.

    Answers

    • Do multi-organization setups rely on one key working across organizations? Yes, it is documented behaviour. Option 1 keeps it wherever the holder has the right in each organization, which is the normal case (for example a Developer in both test and production). It only stops a key in an organization that never granted that right.
    • What happens to existing keys? No key is migrated or deleted. Existing keys keep working wherever their holder is admitted. Elsewhere the next call gets API_KEY_NOT_ADMITTED. Granting a role or competence there restores the key at once, with no reissue. The release notes will call this out.

    Rationale

    A grant "applies in this organization only", and organization B's admins decide through grants who may hold a key in B. Today a role in another organization overrides that, giving REST and MCP access to B that B never granted.

    Checking each call at the one door every key passes through closes this. It reuses the per-organization rule that agent connections and single-sign-on keys already use, and completes the controls shipped for #5045, #5217 and #5218.

    Binding each key to one organization (option 2) would break legitimate use across organizations and force a migration. Keeping the rule (option 3) would only document the hole.

    Implementation units

    1. fix(platform): judge a personal API key's right in each organization it calls (main, via train, M).
      • Changes: extract mayHoldApiKeyIn; add the check and the API_KEY_NOT_ADMITTED code in rest/v1.ts, also for single-sign-on keys; filter the "where it works" lists; update the spec (APIKEY-R14) and the docs in en, de and fr; add a manual-test box.
      • Tests: an Admin in A who is a Member without a grant in B is refused in B on REST, MCP and the model endpoints, and works in A. A grant in B admits the next call; revoking it refuses the next call. Keys made for a member, and team, project and organization keys, are unaffected.
    2. fix(platform): show where a personal API key works in the API settings and key lists (main, via train, M).
      • Changes: the endpoint behind Settings › API › REST reports whether the viewer's keys work here; Create is offered only where they do, with an accessible notice elsewhere; GET /me and "All keys in this organization" leave out organizations where the key doesn't work; the block dialog marks such keys "Doesn't work here"; locale strings in every locale.
    3. fix(platform): fold the key-holding right into the feature line's personal-key standing (release/0.6, via feature-train, S).
      • Changes: after the rebase, combine the check with the "members' personal keys work here" setting and the block into one ordered judgment.
      • Tests: each combination of the setting, the block and the right.

    Cross-issue amendments (decisions taken together with #5404, #5218, #4878, #5374, #5136):

  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: mediumsecurityservice: platform

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions