I am trying to understand the architecture of microservices and I have a question about how to properly authorize a user in the Api gateway or check for its existence if I have a separate User service for registration, login and token issuance. Let's say I have two services: a user service for registration, login and receiving tokens and an ordering service. They have their own databases.
I have guesses:
- For each request to the api gateway, make a separate request to the authorization service and check the token and user role there, and only then redirect the request to the order service.
- Provide Api gateway with access to the user database to verify the token and user and then redirect the request to the order service
- Combine Api Gateway and user service (I think it's a bad idea).
Or are there better guesses?