-
Notifications
You must be signed in to change notification settings - Fork 68
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: Improved error messages/warnings #133
base: main
Are you sure you want to change the base?
Conversation
Thanks for making this @codedust! I like all of the changes other than the new exit status. I have a feeling this may break more workflows than it seems, and I wonder if a new |
This is intended behavior. To prevent users from accidentally skipping signature validation, signature validation should be the default . An exit status of What changes with the merge request is, that if no secret is given via the I would strongly argue against an exit status of From my point of view, the following two options would also be fine:
|
cb37030
to
084ffe4
Compare
Rebased to main |
@codedust the original intent of this tool wasn't only for verification—it was originally just a way to view the contents of a JWT. Verification was secondary. I'm unsure how many people use it just to view the contents of a token, and how many use that in an automated fashion, where a non-zero exit code would break it. I'll need to think about it some more, but I'm still not convinced the default should be changed. I'd rather add a |
@codedust thoughts on making a |
I think, adding a |
02b3ebf
to
115eb64
Compare
New: If no secret/publicKey is provided by the user, no signature check is performed. Rather then silently skipping the signature check, this commit introduces a warning in this case. New: If the `exp` claim is not set and the token validation check is skipped, a warning is shown. New: After a successful signature validation a success message is shown. Changed: The `InvalidAlgorithm` error message now shows the selected algorithm and the algorithm specified in the JWT header. New: If no signature validation is performed, the return code is now `2`. All tests have been updated accordingly.
This commit introduces a verify command that enforces signature validation. The decode command now does not attempt to validate the token signature and does not expect the parameters `--secret`, `--ignore_exp` and `--alg` any more. This commit also includes some additional code cleanups regarding exit codes.
115eb64
to
041f354
Compare
I've now added the Now, the If backwards compatibility is really important, we could also add the parameters to the An alternative would be to add signature verification to the What do you think? |
I kind of like this approach, since it shortcuts the occasional need to do both verification and decoding. It will probably also be useful if this tool ever handles encrypted tokens. It seems like the exit code should always be |
New: If no secret/publicKey is provided by the user, no signature check
is performed. Rather then silently skipping the signature check, this
commit introduces a warning in this case.
New: If the
exp
claim is not set and the token validation check isskipped, a warning is shown.
New: After a successful signature validation a success message is shown.
Changed: The
InvalidAlgorithm
error message now shows the selectedalgorithm and the algorithm specified in the JWT header.
New: If no signature validation is performed, the return code is now
2
.All tests have been updated accordingly.
Summary
Preflight checklist