Skip to content

feat(auth): JWT-bearer helper for WIF client conformance (SEP-1933)#268

Draft
coding-bobo wants to merge 1 commit into
modelcontextprotocol:mainfrom
coding-bobo:worktree-feat+wif-jwt-helper
Draft

feat(auth): JWT-bearer helper for WIF client conformance (SEP-1933)#268
coding-bobo wants to merge 1 commit into
modelcontextprotocol:mainfrom
coding-bobo:worktree-feat+wif-jwt-helper

Conversation

@coding-bobo
Copy link
Copy Markdown

Relates to #223

Problem

Issue #223 adds client conformance tests for Workload Identity Federation (SEP-1933, RFC 7523). The scenario needs a reliable way to generate signed JWT assertions server-side and hand them to the client under test. Without a shared helper, each negative test case would re-implement JWT signing independently.

Design

This is PR 1 of 2. It adds the signing infrastructure only — no scenario is registered and there is no change to runtime behaviour. PR 2 will add the wif-jwt-bearer scenario, everything-client handler, broken example clients, negative vitest cases, registration, and expected-failures baselines.

The helper API mirrors existing patterns in client-credentials.ts (keypair generation, PEM export) and cross-app-access.ts (SignJWT chain). Keypair generation is separate from signing so PR 2's negative tests can sign with a key the AS does not trust without API gymnastics.

Changes

  • helpers/createWorkloadJwt.tsgenerateWorkloadKeypair(alg?) and createWorkloadJwt(opts) plus JWT_BEARER_GRANT_TYPE and DEFAULT_WORKLOAD_JWT_ALG constants. expiresIn accepts a jose duration string or an absolute epoch number — the number form lets PR 2 construct already-expired assertions for negative tests.
  • helpers/createWorkloadJwt.test.ts — 13 unit tests (first isolated unit tests in helpers/): round-trip sign+verify, default 5-minute lifetime, expired-token construction via numeric epoch, unique jti, array audience preservation (RFC 7519 §4.1.3), additionalClaims not overriding reserved claims, caller-supplied jti, notBefore, and algorithm override.
  • cross-app-access.ts — two bare URN string literals replaced with JWT_BEARER_GRANT_TYPE. No behaviour change.

Testing

  • npx vitest run src/scenarios/client/auth/helpers/createWorkloadJwt.test.ts — 13 tests pass
  • npx vitest run — full suite passes (131 tests, 10 files, no regressions)
  • npm run check — typecheck and lint clean

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