Repository navigation
fix(oauth): parse resource_metadata per RFC 7235 auth-param rules - #1771
Merged
Dumbris merged 1 commit intoOct 26, 2026
Conversation
|
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
Dumbris
approved these changes
Oct 26, 2026
Dumbris
left a comment
Member
There was a problem hiding this comment.
Verified: the PR test fails on main for the reason described and passes on this branch merged with main; race tests for the touched packages and CI lint (bare and server tags) are clean. Also built and tested together with the rest of this batch, independently reviewed, and cross-reviewed with a second model.
Member
|
Merged. Thank you, @rudycelekli! |
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.
Bug
ExtractResourceMetadataURL(internal/oauth/discovery.go) finds the PRM URL by splitting the header on the literalresource_metadata=". RFC 7235 section 2.1 allows a case-insensitive parameter name and whitespace around=, so a valid challenge can be missed and discovery falls back to a constructed URL. A plain substring split also misreads other parameters:x_resource_metadata="…"is taken asresource_metadata.error_description, is taken as the real one.Trigger
All of these headers return
""or the wrong URL today:Bearer Resource_Metadata="https://…/oauth-protected-resource"Bearer error="invalid_token", resource_metadata = "https://…"Bearer x_resource_metadata="https://wrong", resource_metadata="https://…"Fix
The function now runs a small auth-param scanner:
=;Token-form (unquoted) values are still rejected, matching the existing "missing opening quote" case.
Verification
go test -count=1 -run TestExtractResourceMetadataURL ./internal/oauth/passes. That covers the new cases and the existingTestExtractResourceMetadataURLtable.discovery.goreverted (git stash push internal/oauth/discovery.go), the new test fails on 4 of its 5 subtests: case-insensitive name, whitespace around=, similar-suffix parameter, and lookalike-only.gofmt -lis clean on both files.go test -count=1 ./internal/oauth/locally. Work stopped because free disk fell below 1 GB.