Design: Service-to-Service Authentication System
Design focuses on authentication between microservices only. Authorization, user authentication, and API gateway design are out of scope.
Functional Requirements
Non-Functional Requirements
Jump into concepts and practice - no test required
+-----------------------+
| Authentication |
| Service |
| (Token Issuer & |
| Validator) |
+-----------+-----------+
|
| Issue tokens (JWT)
|
+----------------+ +-------v--------+ +----------------+
| Microservice 1 | ---> | Token Validation| <--- | Microservice 2 |
| (Client) | | Middleware | | (Client) |
+----------------+ +----------------+ +----------------+
Legend:
- Microservices request tokens from Authentication Service
- Microservices validate tokens locally using middleware
- Authentication Service signs tokens with private key
- Public key distributed to services for verificationtoken = auth_server.issue_token(service_id="serviceA")
if auth_server.verify_token(token):
print("Access granted")
else:
print("Access denied")
What will be printed if the token is valid?