Repository navigation
fix(auth): strip trailing slash in OAuth2 discovery paths - #8478
Open
1828703450qqcom-ux wants to merge 1 commit into
Open
1828703450qqcom-ux wants to merge 1 commit into
1828703450qqcom-ux wants to merge 1 commit into
Conversation
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.
Link to Issue or Description of Change
Problem:
In
src/google/adk/auth/oauth2_discovery.py:discover_auth_server_metadataanddiscover_resource_metadataonly ignoredpath == "/", leaving trailing slashes on path-prefixed URLs (e.g.https://auth.example.com/oauth/orhttps://resource.example.com/tenant1/) intact. This violates RFC 8414 Section 3.1 and RFC 9728 Section 3.1 (which require stripping any terminating/before inserting/.well-known/...) and produced a double slash in the path-appended OpenID Connect discovery URL (https://auth.example.com/oauth//.well-known/openid-configuration).discover_resource_metadatacomparedmetadata.resourceagainstresource_url.rstrip("/")without calling.rstrip("/")onmetadata.resource(unlikediscover_auth_server_metadataat line 137 which callsmetadata.issuer.rstrip("/")), rejecting valid servers that return a trailing slash inresource.Solution:
path = parsed_url.path.rstrip("/")in bothdiscover_auth_server_metadataanddiscover_resource_metadataand checkif path:.metadata.resource.rstrip("/")during MIX-UP validation indiscover_resource_metadata.tests/unittests/auth/test_oauth2_discovery.pycovering path-prefixed trailing-slash discovery URLs and trailing-slashmetadata.resourceresponses.Testing Plan
Unit Tests:
pytest tests/unittests/auth/test_oauth2_discovery.py -q(18 passed)Checklist
Note: Prepared with AI assistance; reviewed and verified locally.