Add Check PCKE Support (#563)

Refer To [Issue
473](https://github.com/modelcontextprotocol/go-sdk/issues/473)
Changes:
- Add check for PKCE support via server metadata and return an error if
not supported.
This commit is contained in:
Ryo Kusnadi 2025-10-14 22:09:28 +07:00 • committed by GitHub
commit 31e97ad69e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -139,6 +139,11 @@ func GetAuthServerMeta(ctx context.Context, issuerURL string, c *http.Client) (*
// Security violation; don't keep trying.
return nil, fmt.Errorf("metadata issuer %q does not match issuer URL %q", asm.Issuer, issuerURL)
}
if len(asm.CodeChallengeMethodsSupported) == 0 {
return nil, fmt.Errorf("authorization server at %s does not implement PKCE", issuerURL)
}
return asm, nil
}
errs = append(errs, err)