JSON Web Token
wahyu agus arifin
What is JWT?
JSON Web Token (JWT) is an open standard (RFC 7519) used for secure and compact data exchange as a JSON token. It is widely used for authentication and authorization in stateless APIs.
JWT Structure
A JWT consists of three parts separated by dots (.):
HEADER.PAYLOAD.SIGNATURE
- Header: token type & algorithm
- Payload: claims (data)
- Signature: integrity verification
How It Works (Short Flow)
- User logs in
- Server generates JWT
- Token is sent to client
- Client sends token with each request
- Server verifies the token
Sample Payload
ex.json
Loading...
Advantages
- Stateless
- High performance
- Ideal for APIs & microservices
Drawbacks
- Hard to revoke
- Payload is readable
- Risky if token leaks
Best Practices
- Always use HTTPS
- Short expiration time
- Implement refresh tokens
- Never store sensitive data
JWT is not just about tokens, but about trust and access boundaries.