fix(openid-connect): ensure identity headers reflect validated tokens#13330
Open
shreemaan-abhishek wants to merge 1 commit intoapache:masterfrom
Open
fix(openid-connect): ensure identity headers reflect validated tokens#13330shreemaan-abhishek wants to merge 1 commit intoapache:masterfrom
shreemaan-abhishek wants to merge 1 commit intoapache:masterfrom
Conversation
The plugin only set X-Access-Token / X-Userinfo / X-ID-Token / X-Refresh-Token when they were not already present in the incoming request, and never cleared client-supplied values for these reserved header names at the start of the request. This made the headers the upstream received depend on what the client sent rather than purely on what the plugin validated. This change clears the four headers at the start of rewrite (snapshotting the X-Access-Token value first since it doubles as a bearer-token input to get_bearer_access_token), and makes add_access_token_header always overwrite, so the upstream consistently sees plugin-controlled values.
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.
Description
The
openid-connectplugin only set theX-Access-Token,X-Userinfo,X-ID-Token, andX-Refresh-Tokenheaders when they were not already present in the incoming request, and it never cleared client-supplied values for these reserved header names at the start of the request. As a result, the headers the upstream received depended on what the client sent rather than purely on what the plugin validated.This PR makes the behavior consistent:
_M.rewrite, snapshot the incomingX-Access-Tokenvalue (it doubles as a bearer-token input viaget_bearer_access_token) and clear all four reserved headers from the upstream-bound request.get_bearer_access_tokento read the snapshot fromctxinstead of the now-cleared header.add_access_token_headerto always overwrite whenset_access_token_headeris true, so the upstream consistently sees plugin-controlled values.A new regression test
t/plugin/openid-connect-identity-headers.tcovers two scenarios:unauth_action = "pass"route: client-supplied identity headers do not bleed through to the upstream when the plugin lets the request pass without authentication.bearer_only = trueroute with an embedded RS256 public key: the upstream receives the validated token inX-Access-Token, not whatever the client sent.Which issue(s) this PR fixes:
Fixes #
Checklist