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 obtain the previously validated JWT from the context, so that I can use it in my custom plugins with lower priority #11281

Open
mikyll opened this issue May 23, 2024 · 0 comments · May be fixed by #11675

Comments

@mikyll
Copy link
Contributor

mikyll commented May 23, 2024

Description

I'd like to extend jwt-auth plugin to save the authenticated JWT in the request context, so that I can easily use it in a plugin which executes after (lower priority), such as a custom ACL. This way I don't have to retrieve it again from the request query parameters, cookies or headers.

Custom plugin example (my-acl.lua):

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

    local jwt_token = ctx.jwt_obj
    if not jwt_token
    then
        -- Technically this can only happen when the JWT plugin didn't run for this request, or the priority was lower
        core.log.warn("\n\nToken object not found in ctx.\n\n")
        return 401, {message = "Missing JWT token in request"}
    end

    -- [...]
end
mikyll added a commit to mikyll/apisix that referenced this issue May 23, 2024
Features:
- Store the JWT object in request context;
mikyll added a commit to mikyll/apisix that referenced this issue May 23, 2024
Features:
- Store the JWT object in request context;
mikyll added a commit to mikyll/apisix that referenced this issue Oct 23, 2024
Fixes apache#11281

Signed-off-by: Michele Righi <righi.michy@gmail.com>
@mikyll mikyll linked a pull request Oct 23, 2024 that will close this issue
5 tasks
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