Just to simplify my situation I currently have 3 micro services.
- Authentication
 - Locations
 - Inventory
 
The authentication service authenticates the user and sends back a JWT access token and I use that across the other services. Its stateless and all works well.
I setup locations among some other things in the location service and this works well and as expected.
But now I am at the inventory service and I need to add some inventory but it is linked to a location. I can easily pass the locationId in the API call but I have no way of authorizing the current user to add something to that location unless I then call the location service to validate this.
This then creates service dependencies between each other and it is something I am trying to avoid at all costs otherwise you just lose most of the benefits of micro services.
What would be the recommended approach to validate that the current user has permissions for that location? The only thing I have thought of so far is either
- Getting the location API to issue out another access token with additional claims of what locations they have access to.
 - Or issuing out another completely separate token of some kind and passing that via the header to the inventory micro service to do a validation similar to how the JWT is authenticated.
 
Edit
As mentioned below on providing aggregate roots (or I am assuming that means the same as API gateways) it would provide the 3rd option of another service on top to communicate to both to provide the information.
However it then leaves a 3rd service dependent upon 2 others, so I just increased my service dependencies.
                        
You microservice design is poor. You are modeling (
locationanditems) 1 class = 1 microservice and this is not a good idea.You shoul modeling microservices like
Aggregate RootsinDDD; even with its own bounded context. So, in your case, you should model anAggregate Rootwithlocation,itemsanduserthat allows to check domain rules atitem addition user action. This could be, i.e., in yourStock Context.Of course, this doesn't mean that you should not have a
Wharehouse Contextin wich you can add, modify and/or deletelocationsand (if no need of depencies to check domain rules) theAggregate Rootis justLocation class. But this is other microservice in another context.This post should help you. It will bring you a big A-HA! in your mind after reading it.