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

Decode JWT in "Authentication: Bearer ..." request header #708

Open
lathspell opened this issue Aug 30, 2023 · 0 comments
Open

Decode JWT in "Authentication: Bearer ..." request header #708

lathspell opened this issue Aug 30, 2023 · 0 comments

Comments

@lathspell
Copy link

lathspell commented Aug 30, 2023

It would be nice if httpbin could decode the JWT that was passed via the "Authentication: Bearer ..." header and show it as JSON.

To avoid confusion, this is different than GET /bearer under "Auth", where one sets his own header.
It should rather be GET /bearer-token-as-json or similar under "Request Inspection".

Decoding the JWT is pretty simple, here is a shell script that I use so far:

echo "$access_token" | cut -d. -f2 | base64 -d --ignore-garbage \
    | jq 'if .iat then (.iatStr = (.iat|gmtime|strftime("%Y-%m-%dT%H:%M:%SZ"))) else . end' \
    | jq 'if .exp then (.expStr = (.exp|gmtime|strftime("%Y-%m-%dT%H:%M:%SZ"))) else . end'

(the last two lines are just a suggestion that decoding the Unix timestamp would be very convenient as well)

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

1 participant