Repository navigation
Conversation
…gured When the AS metadata lists both `none` and a client_secret method, the runner previously selected `none` even for confidential clients with a configured secret, so the token request went out unauthenticated and the confidential-client path was never exercised. When a client secret is configured, prefer client_secret_post / client_secret_basic over `none`. Public clients (no secret) still use `none`, and servers offering only unsupported methods still skip. This fixes modelcontextprotocol#601
commit: |
|
Thanks for picking this up. I verified this branch against AuthPlane, whose metadata advertises
Before this change, both confidential clients sent the code exchange with no credentials and got Two optional suggestions:
Closes #601 from our side once merged. Thanks again! |
|
Thanks for the thorough verification against a live server — especially the dpop token-binding coverage across all three client types. That's exactly the path this was meant to exercise. |
JosephDoUrden
left a comment
There was a problem hiding this comment.
Ran the authorization-code-grant and dpop specs on b50b898: 29/29 pass, eslint and prettier clean. Reverting authorization-code-grant.ts fails 2 of the 3 new tests, so that path is covered. Reverting dpop.ts leaves all 29 green, so dbauthplane's second suggestion still stands: the dpop change has no test yet. LGTM once dpop gets a mirror test.
Mirror the authorization-code-grant coverage for the dpop scenario: when the AS advertises both none and a client_secret method and a secret is configured, the token request must carry client credentials (basic or post); a public client still sends none. Verified by mutation: reverting the selection fix fails the two confidential-client cases.
|
Added the mirror coverage in 0778837: new dpop-token-auth.test.ts exercises the dpop token exchange with a mocked AS advertising both |
This fixes #601.
Problem
When an authorization server's metadata lists both
noneand a client-secret method intoken_endpoint_auth_methods_supported, the authorization-server scenarios pickednoneeven when a client secret was configured. The token request then went out unauthenticated, so servers supporting both methods were never exercised on the confidential-client path.Fix
In
selectTokenAuthMethod(used by bothauthorization-code-grantanddpopscenarios): when a client secret is configured, preferclient_secret_post/client_secret_basicovernone. Behavior is unchanged otherwise:nonewhen offered.noneoffered still falls back tonone.client_secret_jwt,private_key_jwt,tls_client_auth) still skip.Tests
Added three vitest cases in
authorization-code-grant.test.ts:['none', 'client_secret_post']+ secret configured → token request carriesclient_id+client_secretin the body, no Authorization header.['none', 'client_secret_basic']+ secret configured → token request carries the Basic authorization header, noclient_secretbody param.none(regression guard).npm run buildpasses;npm testpasses (644/644).