I am working on microservice application and now thinking how to handle security in service to service call.
For simplicity, imagine I have only two services:
- Api gateway (exposed to the internet)
- Service A (in DMZ, reachable only via API gtw)
Service A has a POST endpoint, let's say POST /customers to create a customer.
I also have POST endpoint on Api Gateway POST /gtw/customers. This works in a way that it does some validation (call some other service) and if everything is ok, then it delegates the request to Service A.
What I want to achieve is that endpoint in service A can be called only by API gateway (so the validation is applied). I am considering two approaches:
- Secure the endpoint in Service A by JWT token and API gateway will generate the token and then it can call the endpoint in Service A
- Leave it as it is because service A is running in DMZ, so it cannot be called directly (so basically it is secured on "infrastructure" level).
Is it good approach at all to handle service to service authentication by JWT tokens?