fix: match complete www-authenticate auth params#3050
Open
pradeep-ramola wants to merge 1 commit into
Open
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.
Fixes #3009
Updates
extract_field_from_www_authso it only matches completeWWW-Authenticateauth-param names. This prevents fields likescopefrom matching inside longer names such aserror_scopeorcustom_scope, and preventsresource_metadatafrom matching insidex_resource_metadata.Motivation and Context
The previous regex searched for the field name without a boundary, so a decoy parameter could shadow the real auth-param value or return a value when the requested parameter was not present.
This matters for OAuth discovery because
resource_metadatafromWWW-Authenticatecontrols the protected resource metadata URL selection.How Has This Been Tested?
Tested locally with:
Scenarios covered:
error_scopebefore realscopecustom_scopewithout realscopex_resource_metadatabefore realresource_metadatax_resource_metadatawithout realresource_metadataBreaking Changes
None.
Types of changes
Checklist
Additional context
The fix escapes the requested field name and requires it to appear at the start of the header or after an auth-param separator, so only complete auth-param names are matched.