Skip to content

feat(auth): WIF JWT-bearer scenario and negative tests (SEP-1933)#269

Closed
coding-bobo wants to merge 3 commits into
modelcontextprotocol:mainfrom
coding-bobo:worktree-feat+wif-jwt-bearer-scenario
Closed

feat(auth): WIF JWT-bearer scenario and negative tests (SEP-1933)#269
coding-bobo wants to merge 3 commits into
modelcontextprotocol:mainfrom
coding-bobo:worktree-feat+wif-jwt-bearer-scenario

Conversation

@coding-bobo
Copy link
Copy Markdown

Context

Implements client conformance for Workload Identity Federation (SEP-1933, RFC 7523 §2.1) — the second of two PRs for issue #223.

Depends on #268 (JWT signing helper). Once #268 merges this will be rebased on main; the diff currently includes both.

What this adds

auth/wif-jwt-bearer scenario (src/scenarios/client/auth/wif-jwt-bearer.ts):

  • Generates an ES256 keypair per start() call (simulates a workload OIDC IdP)
  • Pre-signs three JWT variants and passes them in context: valid_jwt, wrong_audience_jwt, expired_jwt
  • Configures the conformance AS with grant_types: [jwt-bearer] and token_endpoint_auth_method: none
  • Validates the assertion parameter and emits per-class checks:
    • wif-grant-type — rejects unexpected grant types
    • wif-assertion-missing — rejects requests without assertion
    • wif-assertion-expired — rejects expired JWTs (jose.errors.JWTExpired)
    • wif-assertion-audience — rejects wrong aud (JWTClaimValidationFailed with claim === 'aud')
    • wif-assertion-malformed — rejects invalid signatures and other claim failures
    • wif-assertion-verified — success

WifJwtBearerProvider in everything-client.ts:

  • Implements OAuthClientProvider with prepareTokenRequest() returning grant_type=jwt-bearer&assertion=<jwt>
  • Passing null as assertion deliberately omits the parameter (for the missing-assertion negative test)
  • clientMetadata.grant_types: [JWT_BEARER_GRANT_TYPE] so DCR advertises the grant

Negative clients:

  • auth-test-wif-wrong-audience.ts — presents wrong_audience_jwt, triggers wif-assertion-audience
  • auth-test-wif-no-assertion.ts — omits assertion, triggers wif-assertion-missing

Schema and spec refs:

  • src/schemas/context.ts — adds auth/wif-jwt-bearer discriminated union variant
  • src/scenarios/client/auth/spec-references.ts — adds SEP_1933_WIF

Testing

  • npx vitest run src/scenarios/client/auth/index.test.ts — 33 tests pass (13 new: extension scenario loop + 2 WIF negative tests)
  • npx vitest run — 137 tests pass, no regressions
  • npm run typecheck — clean
  • npm run build — clean
  • Run the conformance CLI with a real MCP client that supports the jwt-bearer grant and verify all wif-* checks are SUCCESS

Closes

Part of #223 (WIF client conformance, SEP-1933). Depends on #268.

coding-bobo and others added 3 commits May 12, 2026 09:58
Adds createWorkloadJwt and generateWorkloadKeypair to provide reusable,
tested JWT signing infrastructure for the upcoming wif-jwt-bearer scenario
(PR modelcontextprotocol#2). Also extracts JWT_BEARER_GRANT_TYPE constant and migrates
cross-app-access.ts to use it.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Adds the auth/wif-jwt-bearer client conformance scenario using the RFC 7523
JWT-bearer grant (urn:ietf:params:oauth:grant-type:jwt-bearer).

The scenario pre-signs valid, wrong-audience, and expired JWTs on start()
to simulate cloud workload identity tokens. The conformance AS verifies the
assertion and emits per-class checks (wif-assertion-verified,
wif-assertion-missing, wif-assertion-audience, wif-assertion-expired,
wif-assertion-malformed). Broken example clients exercise the missing-assertion
and wrong-audience failure paths.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@coding-bobo
Copy link
Copy Markdown
Author

Reopening with correct base branch (stacked on #268)

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