Just to simplify my situation, I currently have 3 microservices.
- Authentication
- Location
- Inventory
The authentication service authenticates the user and sends back the JWT access token, and I use it through other services. Its stateless and everything works well.
I set places among other things in the location service, and it works well and as expected.
But now I am in the inventory service, and I need to add some inventory, but it is related to the location. I can easily pass the locationId in an API call, but I have no way to allow the current user to add something to this place unless I call the location service to verify this.
This creates interdependencies between services, and this is what I am trying to avoid at all costs, otherwise you will simply lose most of the benefits of microservices.
What would be the recommended approach to verify that the current user has permissions for this location? The only thing I've been thinking so far is
- Getting the location API to issue another access token with additional statements about where they have access.
- Or issue another completely separate token of some type and pass it through the header to the inventory firmware to perform a check similar to JWT authentication.
Edit
As mentioned below, in order to provide aggregate roots (or I assume that this means the same as API gateways), it will provide a third option of another service from above to communicate with both to provide information.
However, after this, the 3rd service remains dependent on 2 others, so I just increased my service dependencies.
source share