Skip to content

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

Description

@mikyll

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? 🙂

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Status
    ✅ Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions