-
Notifications
You must be signed in to change notification settings - Fork 9
Add client credentials conformance tests (JWT and Basic auth) #55
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
commit: |
…eration Implements SEP-1046 client credentials conformance tests: - auth/client-credentials-jwt: Tests private_key_jwt authentication - auth/client-credentials-basic: Tests client_secret_basic authentication Key changes: - Generate EC P-256 keypair dynamically at test start (no hardcoded keys) - Pass credentials to client via MCP_CONFORMANCE_CONTEXT environment variable - Add context field to ScenarioUrls interface for scenario-specific data - Update client runner to pass context as env var to spawned client process The MCP_CONFORMANCE_CONTEXT env var contains a JSON object with: - client_id: The expected client identifier - private_key_pem: PEM-encoded private key (for JWT scenarios) - client_secret: Client secret (for basic auth scenarios) - signing_algorithm: JWT signing algorithm (defaults to ES256)
efc379a to
f4526ff
Compare
- Generate EC keypair with extractable: true so private key can be exported and passed to clients via MCP_CONFORMANCE_CONTEXT - Fix client_secret_basic scenario to use authorizationHeader param instead of non-existent headers object
Add OAUTH_2_1_CLIENT_CREDENTIALS spec reference pointing to OAuth 2.1 draft section 4.2 (Client Credentials Grant) and include it in all client_credentials conformance checks for both JWT and basic auth flows. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
felixweinberger
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, one comment around iss highlighted by our friend Claude that seems easy enough to add + valuable given it's a MUST in RFC 7523? Not sure if the goal here is to be fully compliant with that RFC though or to just take elements of it.
| }); | ||
|
|
||
| // Verify sub claim matches expected client_id | ||
| if (payload.sub !== CONFORMANCE_TEST_CLIENT_ID) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: Should we assert on payload.iss as well?
Looks like iss is required by this RFC: https://datatracker.ietf.org/doc/html/rfc7523#section-3
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah yea good call.
Per RFC 7523, verify that the JWT issuer (iss) claim matches the expected client_id, in addition to the existing sub claim check. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
Summary
Adds two new conformance test scenarios for SEP-1046 OAuth client_credentials flow:
auth/client-credentials-jwt: Tests client_credentials grant withprivate_key_jwtauthentication (RFC 7523 Section 2.2)auth/client-credentials-basic: Tests client_credentials grant withclient_secret_basicauthenticationWell-known test credentials
Both scenarios use well-known test credentials that SDK implementations should use:
For JWT (private_key_jwt):
conformance-test-clientclient-credentials.tsFor Basic auth (client_secret_basic):
conformance-test-clientconformance-test-secretChanges
ClientCredentialsJwtScenario- verifies JWT assertion signature and claimsClientCredentialsBasicScenario- verifies HTTP Basic auth headercreateAuthServerto pass Authorization header toonTokenRequestcallbackmockTokenVerifierto acceptcc-token-*prefixNote
The existing TypeScript test client uses authorization_code flow, so these scenarios will fail with it. SDK implementations need to add client_credentials support to pass these tests.