Enable additional client conformance scenarios - #1763
Conversation
Add test-local client-credentials flows, wire existing enterprise authorization support, and bind cached OAuth credentials to their authorization server. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
This PR expands OAuth-related client behavior and test coverage to enable additional @modelcontextprotocol/conformance client scenarios, while tightening token-cache safety by binding cached credentials/tokens to the issuing authorization server and adding deterministic token-endpoint authentication selection for the enterprise identity assertion grant flow.
Changes:
- Add authorization-server issuer binding to cached OAuth client credentials/tokens and enforce safe migration/refresh behavior in
ClientOAuthProvider. - Add
IdentityAssertionGrantProviderOptions.TokenEndpointAuthMethodand implement deterministic token endpoint authentication method selection (preferringclient_secret_postwhen supported). - Enable and support additional client conformance scenarios via the conformance test runner, new OAuth helpers, and expanded test coverage.
Show a summary per file
| File | Description |
|---|---|
| tests/ModelContextProtocol.Tests/IdentityAssertionGrantTests.cs | Adds assertions and new tests for token endpoint auth method behavior in the identity assertion grant flow. |
| tests/ModelContextProtocol.ConformanceClient/Program.cs | Extends conformance scenario handling, including special-casing OAuth scenarios and pinning protocol version for select tests. |
| tests/ModelContextProtocol.ConformanceClient/ConformanceOAuthHelpers.cs | Introduces conformance-only helpers for discovery and acquiring tokens for client-credentials and enterprise flows. |
| tests/ModelContextProtocol.AspNetCore.Tests/OAuth/TokenCacheTests.cs | Adds tests ensuring cached tokens/credentials are not refreshed across different authorization servers and validates upgrade/migration behavior. |
| tests/ModelContextProtocol.AspNetCore.Tests/ClientConformanceTests.cs | Enables additional previously-disabled conformance scenarios. |
| src/ModelContextProtocol.Core/Authentication/TokenContainer.cs | Adds AuthorizationServer to bind cached credentials/tokens to the issuing authorization server. |
| src/ModelContextProtocol.Core/Authentication/IdentityAssertionGrantProviderOptions.cs | Adds TokenEndpointAuthMethod option for enterprise identity assertion grant flow configuration. |
| src/ModelContextProtocol.Core/Authentication/IdentityAssertionGrantProvider.cs | Validates token endpoint auth method input and selects an auth method deterministically based on metadata/options. |
| src/ModelContextProtocol.Core/Authentication/IdentityAssertionGrant.cs | Implements client_secret_basic vs client_secret_post vs none behavior for JWT bearer token exchange requests. |
| src/ModelContextProtocol.Core/Authentication/ExchangeJwtBearerGrantOptions.cs | Adds internal TokenEndpointAuthMethod plumbing for JWT bearer grant exchange. |
| src/ModelContextProtocol.Core/Authentication/ClientOAuthProvider.cs | Binds restored/stored cached credentials to the selected authorization server and gates refresh/restore accordingly. |
Review details
- Files reviewed: 11/11 changed files
- Comments generated: 1
- Review effort level: Low
|
Could we validate this in Generated with GitHub Copilot. |
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
5200c3f
Summary
auth/authorization-server-migrationauth/client-credentials-jwtauth/client-credentials-basicauth/enterprise-managed-authorizationsep-2322-client-request-statejson-schema-ref-no-derefprivate_key_jwtclient-credentials acquisition private to the conformance executable rather than expanding the production OAuth API before 2.0Fixes #1731.
Related OAuth pull requests
This does not supersede #1615 or #1496:
ClientOAuthOptions.TokenEndpointAuthMethodoverride for the normal authorization-code/CIMD flow.ClientOAuthOptionsflow.TokenEndpointAuthMethodtoIdentityAssertionGrantProviderOptions, which is the separate enterprise JWT bearer grant flow. It intentionally does not add either proposedClientOAuthOptionsAPI.Those PRs can still address authorization-code client configuration independently. This PR only changes
ClientOAuthProviderwhere required for authorization-server migration and secure cache binding; client-credentials grant implementation remains test-local.Compatibility
The public API additions are optional properties. Existing enterprise callers continue to prefer
client_secret_postwhen it is supported, regardless of metadata array order, and fall back only when necessary.Durable cache entries written before
TokenContainer.AuthorizationServerexisted are not trusted for refresh. They perform a one-time reauthorization so credentials cannot be replayed to an unknown authorization server. Explicit credentials fail closed if a persisted issuer binding later resolves to a different authorization server.Validation
dotnet buildsucceeds with zero warningsDockerEverythingServerTests.Sampling_Sse_EverythingServer; the unfiltered run fails only because the external pinned Everything server reportsUnknown tool: trigger-sampling-request