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

LibJWT needs a robust way to handle keys with various provider and client contexts (i.e. JWKS) #203

Open
lidaobing opened this issue Dec 18, 2024 · 1 comment

Comments

@lidaobing
Copy link

lidaobing commented Dec 18, 2024

In the current design, we have the following prototypes:

typedef int (*jwt_key_p_t)(const jwt_t *, jwt_key_t *);
int jwt_decode_2(jwt_t **jwt, const char *token, jwt_key_p_t key_provider);

If the code runs in a multi-tenant mode, the jwt_key_p_t is hard to write because we always need to know which context we should get the code from. So, could we add a new decode method like the following:

typedef int (*jwt_key_p_ctx_t)(const jwt_t *, jwt_key_t *, void* ctx);
int jwt_decode_3(jwt_t **jwt, const char *token, jwt_key_p_ctx_t key_provider, void* ctx);

If you think the suggestion is valuable, I could provide a patch.

Thanks

@benmcollins
Copy link
Owner

benmcollins commented Dec 18, 2024

I can certainly see the usefulness of this given the currently available functions. However, I really want to move away from this naming and calling convention.

With the new JWK and JWKS support in the master branch coming together nicely, my plan is to have a more robust way to verify and validate (and even decrypt) tokens, and not "decode", as the current function naming implies (it's very confusing to people).

So while I do not intend to to implement jwt_decode_3(), I do intend to to provide the functionality you're looking for.

@benmcollins benmcollins changed the title jwt_decode_2/jwt_key_p_t does not support context LibJWT needs a robust way to handle keys with various provider and client contexts (i.e. JWKS) Dec 18, 2024
@benmcollins benmcollins self-assigned this Dec 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants