oauthex: require S256 PKCE support in GetAuthServerMeta - #1327
Merged
guglielmo-san merged 2 commits intoOct 2, 2026
Merged
guglielmo-san merged 2 commits into
guglielmo-san merged 2 commits into
Conversation
GetAuthServerMeta rejected an authorization server that advertises no PKCE method, but accepted one whose code_challenge_methods_supported lists only "plain". The SDK's clients always send an S256 challenge (oauth2.S256ChallengeOption in auth and auth/extauth), so with such a server the flow failed late, when the authorization endpoint rejected the request in the user's browser, rather than during discovery with a clear error. Require "S256" in the advertised methods. The MCP authorization spec requires clients to use S256 (OAuth 2.1 section 7.5.2), and the TypeScript SDK refuses such a server during discovery in the same way. Servers that offer both methods, such as Google's (see testdata/google-auth-meta.json), are unaffected. The new server_with_only_plain_pkce case of TestGetAuthServerMetaPKCESupport fails without the change; server_with_plain_and_s256_pkce checks that a mixed list is accepted. Fixes modelcontextprotocol#1326 Signed-off-by: Akshita kumari <110122283+akshita317@users.noreply.github.com>
guglielmo-san
approved these changes
Oct 2, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
GetAuthServerMeta rejected an authorization server that advertises no
PKCE method, but accepted one whose code_challenge_methods_supported
lists only "plain". The SDK's clients always send an S256 challenge
(oauth2.S256ChallengeOption in auth and auth/extauth), so with such a
server the flow failed late, when the authorization endpoint rejected
the request in the user's browser, rather than during discovery with a
clear error.
Require "S256" in the advertised methods. The MCP authorization spec
requires clients to use S256 (OAuth 2.1 section 7.5.2), and the
TypeScript SDK refuses such a server during discovery in the same way.
Servers that offer both methods, such as Google's (see
testdata/google-auth-meta.json), are unaffected.
The new server_with_only_plain_pkce case of
TestGetAuthServerMetaPKCESupport fails without the change;
server_with_plain_and_s256_pkce checks that a mixed list is accepted.
Fixes #1326