Repository navigation
fix(core): align OAuth callback iss parameter validation with RFC 9207 metadata - #29616
DavidAPierce merged 3 commits into
Conversation
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request aligns the Gemini CLI's OAuth callback validation with RFC 9207 and the MCP authorization specification. By introducing support for the 'authorization_response_iss_parameter_supported' metadata flag, the system now correctly handles authorization servers that omit the 'iss' parameter in redirects when not explicitly required, resolving authentication failures with services like Notion MCP. Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize the Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counterproductive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here. Footnotes
|
|
📊 PR Size: size/L
|
There was a problem hiding this comment.
Code Review
This pull request updates the OAuth callback flow to conditionally validate the iss (issuer) parameter per RFC 9207 and the Model Context Protocol (MCP) specification. The presence of the iss parameter is now only strictly enforced if the authorization server metadata explicitly declares authorization_response_iss_parameter_supported: true. If this parameter is omitted or false, callbacks without iss are accepted, while mismatched issuers are still rejected. The changes span across the core OAuth provider, utilities, client logic, documentation, and comprehensive unit tests. There are no review comments to assess, and I have no additional feedback to provide.
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request updates the OAuth flow to conditionally validate the iss parameter in authorization responses per RFC 9207 and the MCP specification, ensuring it is only strictly required when the server's metadata sets authorization_response_iss_parameter_supported to true. This prevents connection failures with providers that omit the parameter. The review feedback highlights a critical issue in packages/core/src/tools/mcp-client.ts (in both handleAutomaticOAuth and connectToMcpServer) where the user's explicit configuration for authorizationResponseIssParameterSupported is ignored and overridden by discovered metadata. It is recommended to use nullish coalescing to prioritize the user's settings over the discovered metadata.
cb69455 to
416e295
Compare
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request updates the OAuth callback flow to conditionally enforce the iss (issuer) parameter validation per RFC 9207 and the MCP specification. Specifically, the iss parameter is only required in the callback redirect if the authorization server metadata explicitly declares authorization_response_iss_parameter_supported: true. If this parameter is omitted or false, callbacks without iss are accepted, while any present iss is still validated against the expected issuer. The changes span documentation, core OAuth provider and client logic, callback server handling, and comprehensive unit tests. There are no review comments provided, so I have no feedback to evaluate.
|
✅ 69 tests passed successfully on gemini-3-flash-preview. 🧠 Model Steering GuidanceThis PR modifies files that affect the model's behavior (prompts, tools, or instructions).
This is an automated guidance message triggered by steering logic signatures. |
416e295 to
c5ca57d
Compare
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request introduces support for the authorization_response_iss_parameter_supported metadata parameter from RFC 9207 and the Model Context Protocol (MCP) specification. It allows Gemini CLI to conditionally validate the iss parameter in OAuth callback redirects based on discovered server metadata or explicit user configuration (authorizationResponseIssParameterSupported in settings.json). The changes span the OAuth provider, client, and callback server implementation, accompanied by updated documentation and comprehensive unit tests. I have no feedback to provide as there are no review comments and the implementation is well-tested and documented.
|
Hi luisfelipe-alt,
Regarding PR #29616, the concrete correction for handling the OAuth
callback iss parameter is to use exact comparison after applying the
required decoding. Additionally, we should validate issuer syntax
separately and add regression test cases to cover trailing-slash and other
normalization differences.
Could you please update the implementation and test suite accordingly?
Best regards,
Russell Nordland
…On Mon, Oct 5, 2026 at 10:15 AM gemini-code-assist[bot] < ***@***.***> wrote:
***@***.***[bot]* commented on this pull request.
Code Review
This pull request introduces support for the
authorization_response_iss_parameter_supported metadata parameter from
RFC 9207 and the Model Context Protocol (MCP) specification. It allows
Gemini CLI to conditionally validate the iss parameter in OAuth callback
redirects based on discovered server metadata or explicit user
configuration (authorizationResponseIssParameterSupported in settings.json).
The changes span the OAuth provider, client, and callback server
implementation, accompanied by updated documentation and comprehensive unit
tests. I have no feedback to provide as there are no review comments and
the implementation is well-tested and documented.
—
Reply to this email directly, view it on GitHub
<#29616?email_source=notifications&email_token=BPTYXQFRGCSH4UOYAWMT3MD5SO3KZA5CNFSNUABKM5UWIORPF5TWS5BNNB2WEL2QOVWGYUTFOF2WK43UKJSXM2LFO4XTKNBRGY3DOMJQG4Z2M4TFMFZW63VKON2WE43DOJUWEZLEUVSXMZLOOSWGM33PORSXEX3DNRUWG2Y#pullrequestreview-5416671073>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/BPTYXQB4KZ6OZUS4ELXKJXD5SO3KZAVCNFSNUABFKJSXA33TNF2G64TZHM4TMOBRHE3TEMJWHNEXG43VMU5TKNRYGIYTIMBQG4Y2C5QC>
.
You are receiving this because you are subscribed to this thread.Message
ID: ***@***.***>
|
🟡 Improvements
🟢 Nitpicks
|
…7 metadata Propagate authorization_response_iss_parameter_supported from OAuth authorization server metadata through MCPOAuthConfig, mcp-client, and MCPOAuthProvider to startCallbackServer. Require the iss query parameter in authorization callbacks only when the server explicitly declares authorization_response_iss_parameter_supported: true, while continuing to validate iss against the expected issuer whenever iss is present in the callback response. Fixes google-gemini#29477
Strict boolean check: Restore global.fetch: Schema exposure: Test callback timing (nit): Exact iss comparison: |
c5ca57d to
19ad184
Compare
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request implements support for the authorizationResponseIssParameterSupported configuration option, aligning Gemini CLI's OAuth flow with RFC 9207 and the Model Context Protocol (MCP) specification. It updates the settings schema, configuration interfaces, metadata discovery logic, and the local callback server to dynamically require or accept missing iss parameters based on discovered server metadata or explicit user configuration. Additionally, comprehensive unit tests have been added to verify these behaviors, and the documentation has been updated accordingly. There are no review comments provided, so I have no additional feedback to offer.
Note: Security Review did not run due to the size of the PR.
Summary
This PR aligns OAuth callback
iss(issuer) parameter validation in Gemini CLIwith RFC 9207 and the MCP
authorization specification. Specifically, it requires the
issqueryparameter in authorization callback redirects only when the authorization
server metadata explicitly declares
authorization_response_iss_parameter_supported: true, while continuing tovalidate
issagainst the expected issuer wheneverissis present in thecallback response.
This resolves OAuth authentication failures with MCP servers (for example,
Notion MCP at
https://mcp.notion.com/mcp) that publish anissuerfield in/.well-known/oauth-authorization-servermetadata without declaringauthorization_response_iss_parameter_supported: trueand omitissfrom theauthorization redirect URI.
Details
Per RFC 9207 Section 3,
authorization_response_iss_parameter_supportedis anoptional boolean metadata parameter that defaults to
falsewhen omitted.Previously,
OAuthAuthorizationServerMetadataandMCPOAuthConfigdid nottrack this property, and
startCallbackServer()requiredissin everycallback redirect whenever
expectedIssuerwas configured.This change updates the OAuth discovery and callback pipeline across four core
modules:
packages/core/src/mcp/oauth-utils.ts: Addsauthorization_response_iss_parameter_supported?: booleantoOAuthAuthorizationServerMetadataand maps it toauthorizationResponseIssParameterSupportedinOAuthUtils.metadataToOAuthConfig().packages/core/src/mcp/oauth-provider.ts: AddsauthorizationResponseIssParameterSupported?: booleantoMCPOAuthConfig,preserves the property across both
WWW-Authenticateand standard discoveryconfiguration merges in
MCPOAuthProvider.authenticate(), and passes it tostartCallbackServer().packages/core/src/tools/mcp-client.ts: PropagatesauthorizationResponseIssParameterSupportedwhen buildingoauthAuthConfigin
handleAutomaticOAuth()andconnectToMcpServer().packages/core/src/utils/oauth-flow.ts: Adds an optionalrequireIssInResponse?: booleanparameter tostartCallbackServer()socallbacks missing
issare rejected only whenrequireIssInResponseistrue, while callbacks containingissare always validated withareIssuersEqual(iss, expectedIssuer).oauth-flow.test.ts,oauth-utils.test.ts,oauth-provider.test.ts), adds an integration testsuite (
oauth-callback-iss-handling.test.ts) covering all four combinationsof
authorization_response_iss_parameter_supportedand callbackisspresence, and updates
docs/tools/mcp-server.md.Related Issues
Fixes #29477
How to Validate
Follow these steps to validate the changes locally:
Run the targeted Vitest unit and integration test suites in
@google/gemini-cli-core:npm test -w @google/gemini-cli-core -- \ src/mcp/oauth-callback-iss-handling.test.ts \ src/utils/oauth-flow.test.ts \ src/mcp/oauth-utils.test.ts \ src/mcp/oauth-provider.test.ts \ src/tools/mcp-client.test.tsVerify that all five test suites (252 tests) pass, including the five
scenarios in
oauth-callback-iss-handling.test.ts:isssucceeds whenauthorization_response_iss_parameter_supportedis omitted in metadata.issvalidates issuer matching whenauthorization_response_iss_parameter_supportedistrue.issfails with HTTP 400 whenauthorization_response_iss_parameter_supportedistrue.issvalidates issuer matching even whenauthorization_response_iss_parameter_supportedis omitted orfalse.startCallbackServer()invocation withexpectedIssuerandomitted
requireIssInResponseresolves whenissis absent.Run the linter and TypeScript type checker across all workspaces:
Pre-Merge Checklist