I'm investigating microservices architecture and now focusing on the api gateway along with security.
I found out that there are two different approaches:
1- Where authentication is outside of the gateway, meaning, the user
- has to authenticate first,
- gets the token,
- and then can make calls to the services via the gateway The most common scenario I've seen that everyone is implementing/presenting) as described on the diagram link Authentication outside of the gateway
2- Another way is to have everything behind the gateway, which means, user
- tries to access a secured resource/service via de the gateway,
- he's being redirected to the identity provider login page via the gateway as well,
- gets authenticated, the token is passed back to the client/user,
- and finally reaches the request service, everything through one http call via the gateway which will result in some additional calls (authorization code flow, url call back to the client, as described on the diagram link as well Authentication behind the gateway
And while some might speak about the 2nd approach, I can't seem to find any actual implementation or detailed description. Which makes me wanna ask ... why?
If I'm following a microservices design, I would naturally have the 2nd implementation, but no ... everyone appeared to be using the 1st one.
According to what I've read, yes, it takes more efforts since you'd have to reroute the necessary authentication and authorization endpoint, but is that it? Aren't there any other reasons which would make us favor the 1st one rather the 2nd one?
Any insights?