feat(openid-connect): add hide_credentials attribute#13510
Open
mikyll wants to merge 5 commits 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.
Description
This PR adds a
hide_credentialsattribute to theopenid-connectplugin, mirroring thebehavior already available in other authentication plugins (e.g.
key-auth,basic-auth,hmac-auth).When
hide_credentialsis set totrue, the inboundAuthorizationheader carrying thebearer token is cleared after token validation, so the raw credential is not forwarded
to the upstream service. By default it is
false, preserving the current behavior ofpassing the
Authorizationheader through.Key details:
lua-resty-openidcre-reads theAuthorizationheader while verifying the token.set_access_token_header: when both are enabled, theoriginal credential is removed and the validated access token is added back as a fresh,
plugin-controlled header (
X-Access-Tokenby default).X-Access-Tokenheader is always cleared regardless of this option,so a client cannot smuggle an arbitrary access token to the upstream.
Changes:
apisix/plugins/openid-connect.lua: newhide_credentialsboolean schema field(default
false) and the corresponding header-clearing logic inrewrite.t/plugin/openid-connect-identity-headers.t: new test suite (8 cases) covering identityheader handling — unauthenticated passthrough, client-supplied headers not reaching the
upstream,
hide_credentialswithset_access_token_headerenabled/disabled, and thevalidated-token-vs-client-value distinction.
docs/en/latest/plugins/openid-connect.mdanddocs/zh/latest/plugins/openid-connect.md:documented the new attribute.
Which issue(s) this PR fixes:
Fixes #13279
Checklist