-
Notifications
You must be signed in to change notification settings - Fork 2.1k
fix(auth): treat null optional fields in token responses as absent #2462
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
Open
claude
wants to merge
14
commits into
main
Choose a base branch
from
claude/oauth-tokens-null-fields-v2
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
97ee7bd
fix(auth): treat null optional fields in OAuth token responses as absent
claude 1639827
chore: add changeset for OAuth token null-field normalization
claude 20893fb
fix(auth): normalize null token-response members at parse sites, not …
claude 8d9dee8
docs: note RFC 6749 §5.1 scope-absence semantics of null stripping
claude 4e62b73
chore: retrigger CI (flaky test job on Node 24)
claude e3d7aab
docs: drop core from changeset; correct scope-usage claim in JSDoc
claude 0c105c1
Merge branch 'main' into claude/oauth-tokens-null-fields-v2
claude 791c379
docs: note the null-tolerant token-response wrapper in wire-schemas g…
claude 3219818
feat: export OAuthTokenResponseSchema from core and map it in the v1-…
claude 3501e62
docs: align wrapper wording with its public export; qualify null stri…
claude 8a715bf
fix(auth): preserve stored scope across refresh; fix inverted JSDoc a…
claude 1142f7f
fix(auth): keep scope strictly absent when neither refresh side has one
claude 80adfcf
chore: bump core as minor for the new public OAuthTokenResponseSchema…
claude 0e4a6f1
chore: keep core at patch pending a maintainer call on the bump level
claude File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| --- | ||
| '@modelcontextprotocol/core': patch | ||
| '@modelcontextprotocol/core-internal': patch | ||
| '@modelcontextprotocol/client': patch | ||
| '@modelcontextprotocol/server-legacy': patch | ||
| '@modelcontextprotocol/codemod': patch | ||
| --- | ||
|
|
||
| OAuth token responses with null-valued optional members no longer fail | ||
| validation. Some authorization servers serialize absent optional members as | ||
| JSON `null` (nonconformant with RFC 6749 §5.1, but common in the wild); | ||
| previously `refresh_token`, `scope`, or `id_token` set to `null` failed token | ||
| exchange and refresh, and `expires_in: null` silently coerced to `0`, yielding | ||
| an instantly-expired token. The SDK's own token-response parse sites (client | ||
| token exchange/refresh, JWT-grant cross-app exchange, and the server-legacy | ||
| proxy provider) now validate with a new `OAuthTokenResponseSchema` (defined in | ||
| `@modelcontextprotocol/core`'s auth schema module and forwarded through | ||
| `core-internal`'s re-export shim) that removes | ||
| null-valued optional members before validation, so they are strictly absent | ||
| from the parsed output. The exported `OAuthTokensSchema` is unchanged — still a | ||
| plain object schema, with its `.shape`/`.extend` and input types intact: it | ||
| rejects `null` for its string-typed optional members, though `expires_in: null` | ||
| still coerces to `0` there (use `OAuthTokenResponseSchema` for raw wire | ||
| input). `refreshAuthorization` additionally hardens its merge with the | ||
| previously-stored refresh token, so an explicitly `undefined` `refresh_token` | ||
| in a parsed response can never clobber the preserved token. Note that a | ||
| stripped null `scope` is thereafter indistinguishable from an omitted `scope` | ||
| — which RFC 6749 §5.1 defines as an assertion that the granted scope is | ||
| identical to the requested scope — so consumers should not infer the granted | ||
| scope from its absence. | ||
|
|
||
| `OAuthTokenResponseSchema` is also a public export from | ||
| `@modelcontextprotocol/core`'s root, since the sibling v1 release exports it | ||
| from `@modelcontextprotocol/sdk/shared/auth.js` and migrating code needs a v2 | ||
| home for it. The v1-to-v2 codemod's auth schema allowlist now includes the | ||
| name, so `import { OAuthTokenResponseSchema } from | ||
| '@modelcontextprotocol/sdk/shared/auth.js'` rewrites to | ||
| `@modelcontextprotocol/core` alongside the other auth schema constants. | ||
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
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
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
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
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
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.