Verify a JWT Before Trusting Its Claims
Contrast decoding with verification and trace issuer, audience, algorithm, expiry, and key policy into downstream permissions.
You’re reading a preview. Premium includes the full lesson and specialist practice. View the full curriculum.
Decoding tells you what was written
A JSON Web Token commonly contains an encoded header, payload, and signature. Decoding the first two parts makes their JSON readable. Verification checks the cryptographic proof under a trusted key and allowed algorithm. Validation then establishes whether this token is acceptable for this issuer, recipient, purpose, time, and operation.
An attacker can encode a perfectly plausible payload. Valid JSON, a well-formed UUID, and a recognized role name prove only that the payload follows a shape. If the service trusts those fields before signature verification, the attacker chooses the identity used by later code.
{
"sub": "user-18",
"organization_id": "7b31e2f4-7696-461c-a213-66bf319d280a",
"role": "export-admin",
"iss": "https://login.example.test/",
"aud": "reports-api",
"exp": 2000000000
}