SecurityAlso known as: JSON Web Token, JWT
JSON Web Token (JWT)
A compact, URL-safe means of representing claims to be transferred between two parties. Often used for authentication and authorization.
A JSON Web Token (JWT) is an open standard (RFC 7519) that defines a compact and self-contained way for securely transmitting information between parties as a JSON object. This information can be verified and trusted because it is digitally signed.
JWTs can be signed using a secret (with the HMAC algorithm) or a public/private key pair using RSA or ECDSA.
Structure of a JWT
A JWT consists of three parts separated by dots (.):
- Header: Contains the type of the token (JWT) and the signing algorithm being used (e.g., HMAC SHA256 or RSA).
- Payload: Contains the claims. Claims are statements about an entity (typically, the user) and additional data. There are three types of claims: registered, public, and private claims.
- Signature: To create the signature part, you have to take the encoded header, the encoded payload, a secret, the algorithm specified in the header, and sign that.
The final token looks like this: xxxxx.yyyyy.zzzzz
Common Use Cases
- Authorization: Once the user is logged in, each subsequent request will include the JWT, allowing the user to access routes, services, and resources that are permitted with that token. Single Sign On is a feature that widely uses JWT nowadays, because of its small overhead and its ability to be easily used across different domains.
- Information Exchange: JWTs are a good way of securely transmitting information between parties. Because JWTs can be signed (for example, using public/private key pairs), you can be sure the senders are who they say they are.
Try the Tool
DevFlow provides free, privacy-first tools related to JSON Web Token (JWT). They run completely in your browser.