Understanding JSON Web Token (JWT) Architecture & RFC 7519
A JSON Web Token (JWT) is an open, industry-standard RFC 7519 method for securely transmitting information between parties as a compact, URL-safe JSON object. In modern cloud architecture, microservices, OAuth 2.0, and OpenID Connect (OIDC), JWTs serve as stateless access tokens carrying authentication claims and authorization roles.
1. Anatomy of the Three Segments
A standard JWT string consists of three parts separated by periods (header.payload.signature):
- Header: Specifies the cryptographic algorithm (e.g.,
HS256HMAC-SHA256,RS256RSA Signature, orES256ECDSA) and token type (JWT). - Payload: Contains standard and custom claims (statements about an entity, usually the authenticated user) along with metadata like timestamps. The payload is Base64Url encoded, meaning it is readable by anyone with access to the raw string.
- Signature: Generated by hashing the encoded header, encoded payload, and a secret key or private key. This ensures the token cannot be tampered with or forged in transit.
2. Standard Registered Claims Reference
| Claim | Full Name | Technical Purpose |
|---|---|---|
| sub | Subject | Unique principal identifier (e.g., user UUID or database ID). |
| exp | Expiration Time | Unix timestamp (seconds) identifying when the token expires and must be rejected. |
| iat | Issued At | Unix epoch seconds marking the exact instant the token was minted. |
| iss | Issuer | Identity of the authorization server that generated the token (e.g., Auth0, Firebase, Keycloak). |
| aud | Audience | Identifies the intended recipients or backend API resource servers for this token. |