In my architecture, I have several internal services that need to communicate with each other. I also have a identity access management service that stores information about users, roles and (coarse-grained) permissions.
Components (not exhaustive):
- Service A
- Service B
- IAM service
Rather than giving services A and B full access to each other via IP whitelisting, I would like them to run as users who are managed by the IAM service. So the services need a way of interrogating each other's roles and permissions. I've considered the following approach:
I create opaque API keys for the users that the services will be running under. I store them on each service. When service A calls service B, it passes its API key. Service B then calls the IAM service to validate the key and acquire information about service A's roles before processing the request. Service B caches its responses from the IAM service to reduce chattiness.
I've seen solutions that involve an API gateway, but this assumes that the traffic is coming outside the network. I do not want to redirect internal traffic to the outside just for the sake of converting opaque tokens to by-value JWTs.