Skip to content

[Refactor] Give inbound MCP authentication one request-scoped owner - #3667

Open
roomote-roomote[bot] wants to merge 1 commit into
developfrom
refactor/request-scoped-mcp-auth-85b781ce
Open

roomote-roomote[bot] wants to merge 1 commit into
developfrom
refactor/request-scoped-mcp-auth-85b781ce

Conversation

@roomote-roomote

Copy link
Copy Markdown
Contributor

​Created by Roomote. View the session or mention @roomote-roomote for follow-up asks.

Related issue

Authentication ownership follow-up to #3657.

Why this PR exists

  • A maintainer explicitly invited this PR in the linked issue or discussion
  • I am a maintainer / this is internal Roomote work

OAuth grant validation also records activity in Redis. Middleware and the member resolver both performed that transaction, while the legacy MCP resolver repeated audience/scope checks and rewrote the credential resource to reuse canonical authorization.

What changed

  • Keep live-grant authentication in token middleware and expose its result through a private request-context WeakMap. Member OAuth authorization requires that exact request's authenticated credential; installing a plain auth object cannot bypass ingress validation.
  • Consolidate member audience/scope authorization in the member resolver, with explicit legacy-audience opt-in. Remove the resource-rewriting adapter and duplicate legacy policy branches.
  • Keep trusted internal user calls, legacy run-token handling, and member task visibility checks intact. Model discovery and artifact downloads consume the same request-authentication boundary.

Impact

No intended user-facing behavior change. Each inbound OAuth request checks/touches its grant once, and every subsequent request authenticates afresh. Revocation, deleted-user rejection, Redis fail-closed behavior, and legacy audience restrictions remain enforced. Redis storage and grant state are unchanged.

How it was tested

  • 79 focused tests passed across token middleware, model discovery unit/HTTP access, task output/download access, and route-policy enforcement.
  • Real HTTP requests with signed OAuth tokens and real Redis grants cover public/legacy MCP, model listing, subsequent-request revocation, reconnection, removed users, original legacy audience identity, and one live-grant call per request. Download access tests retain real middleware/database/Redis while mocking JWT decoding and artifact object storage.
  • Injected Redis errors are denied on all four OAuth surfaces; a forged OAuth context without ingress is rejected.
  • API typecheck and pre-push gates passed: monorepo oxlint, residual ESLint, fast typechecks, and knip. Formatting was applied to all changed files. Formatting-inclusive pnpm lint / pnpm check-types were not separately run.
  • Browser proof is not applicable to this backend-only ownership refactor.

Checklist

  • The PR title follows the repo convention: [Fix], [Feat], [Improve], [Refactor], [Docs], or [Chore] followed by a user-facing description
  • This PR is small and scoped to one change
  • pnpm lint and pnpm check-types pass locally
  • I added tests or included a clear manual validation note above
  • I removed secrets, tokens, private keys, and customer data from code, logs, and screenshots
  • If this change should appear in the changelog, I ran pnpm changeset

No changeset: behavior-preserving internal refactor.

@roomote-community

roomote-community Bot commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor

No code issues found. See session

Reviewed all 10 changed files and the authentication, route mounting, and in-process member-tool dispatch paths. CI tests, lint, type checks, and Knip passed for this commit; Docker build and JavaScript/TypeScript CodeQL analysis were still running at review completion.

Reviewed 1d3c10c

@roomote-roomote
roomote-roomote Bot marked this pull request as ready for review November 5, 2026 02:33

This branch has not been deployed

No deployments
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