feat(jwt-auth): support key_claim_name in JWT header#13379
Open
esistfarouk wants to merge 1 commit into
Open
Conversation
…in the header not payload
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
Summary
Currently, the
jwt-authplugin strictly searches for thekey_claim_name(used to identify the Consumer) within the JWT Payload. However, many identity providers and standard JWT implementations place the Key ID (kid) or issuer (iss) solely in the JWT Header.This PR enhances the plugin to look for the claim in both the Payload and the Header, ensuring broader compatibility with standard OIDC and third-party JWT providers.
Why this is needed
In many security architectures, the Header contains the metadata required to identify which key or secret should be used to verify the signature. By restricting the lookup to the Payload, APISIX currently forces developers to either:
kidinto the Payload.This change makes the
jwt-authplugin more robust and "plug-and-play" for modern authentication flows.Changes
find_consumerinapisix/plugins/jwt-auth.lua.user_keylookup to check the JWT Header if the claim is missing from the Payload.Verification Results
kidin Header only (HS512) -> Passed (Consumer identified, Signature verified).