Why JWTs became popular for authentication
A JWT lets a server verify a request without looking up session data in a database on every call, since the token itself carries verifiable claims and an expiration. This statelessness makes JWTs convenient for distributed systems and APIs, at the cost of being harder to revoke instantly compared to a traditional server-side session.
Decoding a token and verifying it are entirely different operations
Anyone can decode a JWT's header and payload without any key at all, since it is just encoding. Verifying that a token is authentic and unmodified requires the specific signing key or public key used to create it β a decoded-but-unverified token should never be trusted as proof of anything.
Frequently Asked Questions
If I can read a JWT's payload without a password, is that a security flaw?
No β it is expected behavior by design. JWTs are meant to be readable; the security guarantee they provide is integrity (tamper-evidence) via the signature, not confidentiality of the payload contents.
Can I edit a JWT's payload and have it still work?
You can edit the decoded text, but re-encoding it without the correct signing key produces an invalid signature, so a server that properly verifies tokens will reject the modified token rather than accepting the edited claims.