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

feat: As a user, I want to use "iss" JWT claim, so that I can verify my Apisix Consumers with a claim different than "key" #11276

Open
mikyll opened this issue May 22, 2024 · 0 comments · May be fixed by #11282

Comments

@mikyll
Copy link

mikyll commented May 22, 2024

Description

I'd like to extend jwt-auth plugin to add a new configuration parameter:

  • key_claim_name (default value: key). that can be used to specify a different key claim name, to validate the JWT against an Apisix Consumer.

Lil snippet for reference:

function _M.rewrite(conf, ctx)
    -- [...]

    local key_claim_name = conf.key_claim_name
    local user_key = jwt_obj.payload and jwt_obj.payload[key_claim_name]
    if not user_key then
        return 401, {message = "Missing " .. key_claim_name .. " claim in JWT token"}
    end

    -- [...]
end

Since it would be set to key by default, it shouldn't change/break any existing setting, but would be helpful for those who are using different JWT "formats".

For example, the company I'm working at is using iss claim as Consumer key. Since we're already using a custom version of the jwt-auth plugin (with this feature implemented), I'd like to integrate this contribution to the official plugin.


Do you think I can make a PR with the changes? 🙂

@mikyll mikyll changed the title feat: As a user, I'd like to use "iss" JWT claim to verify my Apisix Consumers feat: As a user, I want to use "iss" JWT claim, so that I can verify my Apisix Consumers with a claim different than "key" May 23, 2024
mikyll added a commit to mikyll/apisix that referenced this issue May 23, 2024
Features:
- config param "key_claim_name" (default = "key"), so for example one could use "iss" to check the validity of the JWT;

Style:
- 2 blank lines between functions;
- 1 blank like before "else" and "elseif";
- jwt -> JWT;
- Capitalized logs and response messages;
- Added description for each schema configuration parameter;
mikyll added a commit to mikyll/apisix that referenced this issue May 23, 2024
Features:
- config param "key_claim_name" (default = "key"), so for example one could use "iss" to check the validity of the JWT;

Style changes:
- 2 blank lines between functions;
- 1 blank like before "else" and "elseif";
- jwt -> JWT;
- Capitalized logs and response messages;
- Added description for each schema configuration parameter;
mikyll added a commit to mikyll/apisix that referenced this issue May 23, 2024
Features:
- config param "key_claim_name" (default = "key"), so for example one could use "iss" to check the validity of the JWT;

Style:
- 2 blank lines between functions;
- 1 blank like before "else" and "elseif";
- jwt -> JWT;
- Capitalized logs and response messages;
- Added description for each schema configuration parameter;
@mikyll mikyll linked a pull request May 23, 2024 that will close this issue
5 tasks
mikyll added a commit to mikyll/apisix that referenced this issue Jun 4, 2024
I added a new test case for feature apache#11276

Since the default value of the new config parameter "key_claim_name" is "key", "default behaviour" is already validated by other tests.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: 📋 Backlog
Development

Successfully merging a pull request may close this issue.

1 participant