Jwt online tool performs JSON Web Token decode, verify signature and token generation based on given input data.
Note - Algorithms HS256, HS384 and HS512 are currently supported. Rest (ES256, ES384, ES512, RS256, RS384, RS512, PS256, PS384, PS512 and EdDSA) will be supported soon
What is JSON Web Token (JWT)?
A compact, URL-safe means of representing claims to be transferred between two parties.
How does JWT look like?
In its compact form, JSON Web Tokens consist of three parts separated by dots (.), which are:
Header
Payload
Signature
Therefore, a JWT typically looks like the following. xxxxx.yyyyy.zzzzz
JWT Structure:
Data
Description
Header
{ "alg": "HS256", "typ": "JWT" }
Identifies which algorithm is used to generate the signature
HS256 indicates that this token is signed using HMAC-SHA256.
Standard fields : Token type (typ), Content type (cty), Message authentication code algorithm (alg), Key ID (kid), x.509 Certificate Chain (x5c), x.509 Certificate Chain URL (x5u), Critical (crit)
Payload
{ "loggedInAs": "admin", "iat": 1422779638 }
Contains a set of claims. The JWT specification defines seven Registered Claim Names which are the standard fields commonly included in tokens.
This example has the standard Issued At Time claim (iat) and a custom claim (loggedInAs).. Standard fields ("claims") : Issuer (iss), Subject (sub), Audience (aud), Expiration Time (exp), Not Before (nbf), Issued at (iat), JWT ID (jti)
The signature is calculated by encoding the header and payload using Base64url Encoding and concatenating the two together with a period separator
Is JWT for authentication?
No. Since JWT process start only after successful authentication, JWT is only for authorization.
What are advantages of JWT?
No backend store - As server encodes all the data about the grant into the token itself, No data stored at server except secret
No Session to Manage (stateless) - JWT is a self-contained token (and gets stored at client side,) server does not need to keeps track of it
Supports scaling - As no session tracked, single point of failure (SPOF) of 'shared session cache' / session affinity avoided in multiple server instance
More compact - As JSON is less verbose than XML so when encoded it's more compact as compaired to simple web tokens (SWTs) and Security Assertion Markup Language (SAML) tokens
More secure -Even though it can be read by anybody but it can not be tampered. JWT supports varius algoriths that supports public/private key pair, symmetrically signed, so on
Portable - A single token can be used with multiple backends. ideal in micro service environment with 2/3 legged token
Decoupled/Decentralized - The token can be generated anywhere. Authorization can happen on the resource server, or easily separated into its own server
What are disadvantages of JWT?
Can't easily revoke an access token, so they normally are granted with short expiry and the revocation is handled at the refresh token
Unless In secure communication, a token can be stolen and misused. Https communication recommended