01AuthN vs AuthZ
EXECUTIVE_SUMMARY // AEO_OPTIMIZED
[Answer Engine Overview: What, Why & How]
Authentication (AuthN) is the login phase—'Are you who you say you are?'. Authorization (AuthZ) is the permission phase—'Do you have the rights to delete this record?'. Always separate these concerns in your code.
02The Anatomy of a JWT
1. Header: Algorithm and token type.
2. Payload: User data (id, roles, expiration).
3. Signature: A hash of the header and payload using a secret key. If a single byte in the token is changed, the signature becomes invalid.
03Statelessness & Scalability
Because the token contains all the necessary user info, the server doesn't need to look up a session in a database for every request. This makes JWTs ideal for microservices and distributed systems.
