I'm designing a microservice based application with two API endpoints, and one of them is for user access. Users, authenticated with JWT, can belong to different organizations which are in turn organized hierachically. Each user can have some role, which are defined for every organization type; the combination beetween organization and roles define which API could be accessed from user (method and resource) . In conclusion, it can become a mess!
There are several libraries that provide ACL features, but i'm wondering where to put them: the first solution seems to be the API gateway, which should call a component for each request.
-the JWT includes the list of role IDs for the user -API gateway validates JWT and uses the role Ids to lookup in a table where each role has a list of permissions (ex. can POST /users) -if the role matches with request, the latter is forwarded to the right service; otherwise, the gateway responds with 403
The other options is to put a 'auth-service' into architecture. The gateway simply forwards all the requests delivered to the right service, each service (which might depend on a common library) sends the token to the auth service and request grant to satisfy request. In this case, the auth service is the 'right service' for all requests under the /auth resource, gives login/logout, token refresh and registration of new users (like when you click on the link provided into sign in mails)
The first solution provides for a 'fat gateway' which has a tiny layer on logic, but enforces all the service to respond only to secure calls, factorize out all the authentication/orization logic and not adds dependencies beetween services but
- is it the right way to do it?
- are there api gateway implementations that provide that features
- there are some other advantages/disadvantages in both approaches that i don't see
thank you for the answers!!!