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

allow verifying the token against a JWKS #38

Open
bsmedberg-xometry opened this issue Jan 16, 2024 · 1 comment
Open

allow verifying the token against a JWKS #38

bsmedberg-xometry opened this issue Jan 16, 2024 · 1 comment

Comments

@bsmedberg-xometry
Copy link

I'd like to add a feature to jwtinfo that allows specifying an optional JWKS URL to verify the token against.

Here's my thought about what it might look like: jwtinfo --jwks=https://mydomain.us.auth0.com/ <token>

There are a couple different ways you could handle output/validation errors:

  • no stdout, print error to stderr and exit with a non-zero code
  • print data to stdout even if the token is invalid, print error to stderr, exit with non-zero code
  • In combination with Allow dumping both header and body #37, extend the output format of the "full" output to include extra keys including valid: bool and validationErrors: str[]

@lmammino interested in your thoughts about whether you'd accept a PR, and suggestions for shaping a reasonable CLI surface.

@lmammino
Copy link
Owner

hello @bsmedberg-xometry!

This is another feature I have been thinking about. In broader terms thinking about supporting JWT validation could also cover other aspects beyond just the signature:

  • time validation
  • audience
  • issuer
  • other arbitrary claims

I haven't come up to a conclusion on what would be a good UX for this, but most likely this could be a subcommand.

A very rough sketch could look like this:

jwtinfo validate \
  [--jwks=<jwk_endpoint>] \
  [--iss=<expected_issuer>] \
  [--aud=<expected_audience>] \
  [--ignore-time-validity] \ # to disabel checks on timing constraints
  [--check-claim=<"name:value">] \  # can be repeated multiple times
  <token>

What do you think?

In terms of outputs, it would be nice to have detailed failure messages (why the validation failed).

For success: status code 0 and a simple message "the token is valid" could do...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants