Reputation: 496
I'm new to microservices and system design, and I'm trying to understand the role of the API Gateway in authentication and authorization.
I've come across two different approaches, each with its pros and cons:
1. API Gateway Handles Authorization
In this approach, the API Gateway:
Pros:
Cons:
2. Each Microservice Handles Authorization
Here, each microservice:
Pros:
Aligns with a zero-trust security model.
Each service enforces its own security, reducing reliance on the
gateway.
Cons:
Question
Which approach is more widely adopted in the industry, and what factors should be considered when choosing between these models?
Upvotes: 0
Views: 22
Reputation: 9446
This is more robustly answered here: Microservice authorization pattern with api gateway, but in general you really want to couple your authorization in your service-layer, otherwise you will quickly create a "god-object" anti-pattern in your gateway. It will very quickly violate Single Responsibility Principal when your gateway has deep knowledge of the inner workings of all the services that it fronts.
Upvotes: 0