Skip to content

fix(auth): resolve API-key tenants with the key's pinned roles#244

Closed
Makisuo wants to merge 1 commit into
mainfrom
fix/api-key-role-plumbing
Closed

fix(auth): resolve API-key tenants with the key's pinned roles#244
Makisuo wants to merge 1 commit into
mainfrom
fix/api-key-role-plumbing

Conversation

@Makisuo

@Makisuo Makisuo commented Jul 21, 2026

Copy link
Copy Markdown
Collaborator

What

Main CI is red: 3 tests in apps/api/src/routes/v2/api-keys.http.test.ts fail with expected 200 to be 403.

#242 pinned creator roles onto MCP keys and added tests asserting a member key cannot create standard API keys or revoke other users' keys — but the authorization layers still stamp every resolved API key with the default (root) roles, so the restrictions never apply.

This plumbs resolved.roles through:

  • ApiAuthorizationLayer (v1)
  • ApiAuthorizationV2Layer (v2)
  • resolveMcpTenantContext (MCP)

falling back to apiKeyDefaultRoles for keys without pinned roles (unchanged behavior for existing standard keys).

Verification

On a clean checkout of main: api-keys.http.test.ts fails 3/16 → with this change 16/16 pass, and the full apps/api suite passes (948 tests; the one failing file locally, AiTriageWorkflow.run.test.ts, is only a missing local effect-sdk dist build — CI builds it).

🤖 Generated with Claude Code


View with Codesmith Autofix with Codesmith
Need help on this PR? Tag /codesmith with what you need. Autofix is disabled.

PR #242 pinned creator roles onto MCP keys and added tests asserting a
member key cannot create standard keys or revoke other users' keys, but
the authorization layers still stamped every resolved API key with the
default (root) roles, so those restrictions never applied and the tests
fail on main (200 instead of 403).

Plumb resolved.roles through the v1 and v2 authorization layers and the
MCP tenant resolver, falling back to the defaults for keys without
pinned roles.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@pullfrog

pullfrog Bot commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

Your Pullfrog Router balance is exhausted.

You have a card on file but auto-reload is disabled, so runs paused once your balance went past the overdraft buffer.

Top up balance → · Enable auto-reload →

Pullfrog  | ⚠️ this action is pinned to a commit SHA, which freezes the cleanup step — switch to @v0 or keep the SHA fresh with Dependabot | Rerun failed job ➔View workflow run | via Pullfrog | Using Claude Opus𝕏

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant