Enterprise Java
jwt-cli: A Shell Library to Decode JSON Web Tokens (JWT Tokens)
When I started having the need of decoding JSON Web Tokens quite often, I felt the urge of writing a program that allowed me to do it quickly. There are excellent options, such as jwt.io, but as soon as you need to do this operation often it becomes clumsy. And if you need to process multiple tokens, or further process the output, it becomes a necessity.
That’s why I wrote a little shell script that allows you to do just that. jwt-decode will accept a list of tokens as arguments and will decode them on standard output. The syntax is the following:
$ jwt-decode token ... { "alg": "RS256", "typ": "JWT", "kid": "sbS_BWBm0GzfIQRnYWolcWDRnjqwDTY_Aq6Fn_boqKM" } { "jti": "271151a3-db11-4f37-a724-4cf9957774f4", "exp": 1530979706, "nbf": 0, "iat": 1523117306, "iss": "https://domain.com/auth/realms/realm", "aud": "app-name", "sub": "5132c417-d772-420e-b5db-401ea633dca1", "typ": "Bearer", "azp": "app", "auth_time": 0, "session_state": "84e6a759-e54d-4fd7-9fcf-bb51131aab89", "acr": "1", "allowed-origins": [ "" ], "realm_access": { "roles": [ "role0", "role1", "role2" ] }, "resource_access": { "account": { "roles": [ "manage-account", "manage-account-links", "view-profile" ] } }, "custom-property": "1797" } ...
You can find jwt-cli on GitHub.
Published on Java Code Geeks with permission by Enrico Crisostomo, partner at our JCG program. See the original article here: jwt-cli: A Shell Library to Decode JSON Web Tokens (JWT Tokens) Opinions expressed by Java Code Geeks contributors are their own. |