Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhance jwt-auth Plugin with Configurable Claim Name and Support for Asymmetric Algorithms #11511

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

knownasmobin
Copy link

Description

This PR introduces a new feature and several enhancements to the jwt-auth plugin in Apache APISIX. The key change is the addition of a configurable key_claim_name parameter, which allows users to specify the JWT claim used for identifying the user. This provides greater flexibility and enables integration with a wider variety of JWT issuers and token structures.

Key Changes:

  1. Configurable JWT Claim Name (key_claim_name): Users can now specify which claim in the JWT payload should be used to identify the user (e.g., iss for the issuer claim).
  2. Support for Asymmetric Algorithms (RS256, ES256): The plugin now supports JWTs signed with asymmetric algorithms, with new configuration fields for public_key and private_key.
  3. Schema Enhancements: Descriptions have been added to several schema properties, improving clarity. The schema has also been restructured for better readability and maintainability.
  4. Backwards Compatibility: The default behavior remains unchanged, ensuring that existing configurations continue to work without modification.

This change addresses the following:

  • Increases flexibility in JWT validation, allowing integration with a broader range of JWT issuers and formats.
  • Aligns APISIX's JWT validation with existing authentication systems without requiring token modifications.
  • Enhances security by providing precise control over which claim is used for user identification.

Fixes: Issue #11276

Checklist

  • I have explained the need for this PR and the problem it solves.
  • I have explained the changes or the new features added to this PR.
  • I have added tests corresponding to this change, including tests for both symmetric and asymmetric JWT validation.
  • I have updated the documentation to reflect this change.
  • I have verified that this change is backward compatible (If not, please discuss on the APISIX mailing list first).

@dosubot dosubot bot added size:XL This PR changes 500-999 lines, ignoring generated files. doc Documentation things enhancement New feature or request labels Aug 20, 2024
Copy link
Contributor

@shreemaan-abhishek shreemaan-abhishek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please keep your PR focused. One PR should do only one thing, else it becomes very difficult to review your code.

For this PR, it is advisable to introduce support for configurable claim name and only that. Thanks.

@shreemaan-abhishek
Copy link
Contributor

it seems, this PR would be a duplicate of #11282.

Support for Asymmetric Algorithms (RS256, ES256)

If you want to introduce this support, please do so in another PR with the proposal written in an issue.

@shreemaan-abhishek shreemaan-abhishek added the duplicate This issue or pull request already exists label Sep 20, 2024
@shreemaan-abhishek shreemaan-abhishek marked this pull request as draft September 20, 2024 05:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
doc Documentation things duplicate This issue or pull request already exists enhancement New feature or request size:XL This PR changes 500-999 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants