0
0
Microservicessystem_design~12 mins

JWT token propagation in Microservices - Architecture Diagram

Choose your learning style9 modes available
System Overview - JWT token propagation

This system demonstrates how a JSON Web Token (JWT) is propagated securely across multiple microservices to authenticate and authorize user requests. The key requirement is to ensure that each microservice can verify the token without needing to re-authenticate the user, enabling seamless and secure communication.

Architecture Diagram
User
  |
  v
Load Balancer
  |
  v
API Gateway
  |
  v
+----------------+       +----------------+       +----------------+
|  Service A     | ----> |  Service B     | ----> |  Service C     |
| (Auth Verify)  |       | (Auth Verify)  |       | (Auth Verify)  |
+----------------+       +----------------+       +----------------+
       |                        |                        |
       v                        v                        v
   Database A               Database B               Database C
       ^                        ^                        ^
       |                        |                        |
     Cache A                 Cache B                  Cache C
Components
User
user
Initiates requests with JWT token
Load Balancer
load_balancer
Distributes incoming requests evenly to API Gateway instances
API Gateway
api_gateway
Entry point for requests; validates JWT token and forwards requests to microservices
Service A
service
First microservice that verifies JWT token and processes request
Service B
service
Second microservice that receives JWT token from Service A and verifies it
Service C
service
Third microservice that receives JWT token from Service B and verifies it
Database A
database
Stores data for Service A
Database B
database
Stores data for Service B
Database C
database
Stores data for Service C
Cache A
cache
Caches frequent queries for Service A
Cache B
cache
Caches frequent queries for Service B
Cache C
cache
Caches frequent queries for Service C
Request Flow - 17 Hops
UserLoad Balancer
Load BalancerAPI Gateway
API GatewayService A
Service ACache A
Cache AService A
Service ADatabase A
Service AService B
Service BService B
Service BCache B
Cache BService B
Service BDatabase B
Service BService C
Service CService C
Service CCache C
Cache CService C
Service CDatabase C
Service CUser
Failure Scenario
Component Fails:API Gateway
Impact:All incoming requests fail to be authenticated and routed, causing service unavailability.
Mitigation:Deploy multiple API Gateway instances behind the load balancer for redundancy and failover.
Architecture Quiz - 3 Questions
Test your understanding
Which component is responsible for initially validating the JWT token?
AService C
BLoad Balancer
CAPI Gateway
DCache A
Design Principle
This architecture shows how JWT tokens are propagated and verified at each microservice to maintain secure, stateless authentication. Using an API Gateway centralizes initial token validation, while each service re-verifies tokens to ensure trust. Caches reduce database load, and load balancers provide scalability and fault tolerance.