Anatomy of a JSON Web Token
A standard JWT consists of three distinct parts separated by dots (.):
- Header: Specifies the signature algorithm (e.g.,
HS256,RS256) and token type (JWT). - Payload: Contains assertions (claims) such as
sub(User ID),iss(Issuer),exp(Expiration Time), and custom user roles. - Signature: Cryptographic signature generated by hashing the encoded Header and Payload using the server secret key.
---
Mandatory Steps for JWT Validation
When a backend microservice receives a JWT in the Authorization: Bearer <token> header, it must complete five validation checks before accepting the request:
- Validate Token Structure: Verify that the token string contains exactly two dot separators dividing three distinct Base64URL-encoded segments.
- Enforce Expected Signature Algorithm: Prevent algorithm confusion attacks by strictly enforcing the expected signing algorithm. Never accept tokens containing "alg": "none".
- Verify Cryptographic Signature: Recompute the cryptographic signature using your trusted secret key or public key.
- Verify Expiration Time (exp): Compare the current Unix timestamp against the token
expclaim. - Verify Issuer (iss) and Audience (aud): Ensure the issuer claim matches your authentication service domain.
---
Inspect and Decode JWT Tokens Instantly with Yurlie
Inspect JWT headers, claims, and payloads directly in your browser without sending tokens over the network using the free Yurlie JWT Decoder.
Try Yurlie Online Developer Tools
Run CIDR calculations, JSON formatting, Base64 encoding, and UUID generation instantly in your browser.