Exploring the Pros and Cons of Simple JWT (JSON Web Tokens)

If you're working with authentication and authorization, you've likely encountered JWTs in your projects. Here's a quick breakdown.
Pros
- Stateless and scalable: JWTs are stateless, which means no need for server-side storage. They're easily scalable in distributed systems.
- Compact and efficient: being compact in size, JWTs are efficient for transmitting data between parties, making them ideal for web applications.
- Standardized: JWTs follow a standard, making them interoperable across different platforms and languages.
- Security: when implemented correctly, JWTs can enhance security by providing a way to verify the integrity of the information.
Cons
- No revocation mechanism: once issued, it's challenging to revoke a JWT. If a token is compromised, it remains valid until it expires.
- Size: while compact, JWTs can become large if they carry a significant amount of information, potentially impacting network performance.
- Limited built-in encryption: JWTs have built-in signature verification, but they lack built-in encryption for the payload. Additional measures may be needed for sensitive data.
- Token bloat: as more information is added to the token, there's a risk of "token bloat," where the token becomes unwieldy.
My take
Use short-lived access tokens with refresh token rotation, keep payloads minimal, and never put sensitive data inside a JWT payload: signed is not encrypted.