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

Trim potential whitespace around jwt before decoding #120

Merged
merged 1 commit into from
Feb 14, 2021

Conversation

x3ro
Copy link
Contributor

@x3ro x3ro commented Feb 6, 2021

Summary

Given that JWTs are base64 encoded and can thus not have leading
or trailing whitespace, it is safe to trim the string before
decoding (e.g. the decoder on jwt.io appears to do the same). This
is mostly a convenience feature for people using jwt-cli like this:

# pbpaste prints the text from the clipboard on macOS
pbpaste | jwt decode -

When copying from UIs such the Fx developer tools it's not always
trivial to copy the value without any whitespace, and this change
avoids the extra step of having to remove that whitespace manually.
Of course e.g. piping through xargs would also be an option, but
is, in my opinion, very obscure especially when used in scripts.

Preflight checklist

  • Code formatted with rustfmt
  • Relevant tests added
  • Any new documentation added (unclear whether necessary)

PS: Thanks for writing this nice tool 👍🏼 🚀

Given that JWTs are base64 encoded and can thus not have leading
or trailing whitespace, it is safe to trim the string before
decoding (e.g. the decoder on jwt.io appears to do the same). This
is mostly a convenience feature for people using jwt-cli like this:

    # pbpaste prints the text from the clipboard on macOS
    pbpaste | jwt decode -

When copying from UIs such the Fx developer tools it's not always
trivial to copy the value without any whitespace, and this change
avoids the extra step of having to remove that whitespace manually.
Of course e.g. piping through `xargs` would also be an option, but
is, in my opinion, very obscure especially when used in scripts.
@mike-engel
Copy link
Owner

Thanks @x3ro!

@mike-engel mike-engel merged commit 7ce4d5c into mike-engel:master Feb 14, 2021
@mike-engel
Copy link
Owner

Released with 4.0.0

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

Successfully merging this pull request may close these issues.

None yet

2 participants