I am developing app using Microservice Architecture. Need to implement Security.
So I am planning to achieve this using 3 services.
- API Gateway
- Users Service
- Orders Service
Step1: client sends username and password to API Gateway to get token. API Gateway should call Users Service to validate the creds, if creds are valid API Gateway creates a token and sends it to the client.
Step2: Client tries to access order service using the token (which API Gateway sent in Step1), so API Gateway has to call Users Service to authenticate the token.
I am thinking to have all Authorization and Authentication logic in my API Gateway microservice. So for that when I get a JWT token from consumer at API Gateway I should call Users Service to validate it against the username and password, because I stored all user related data in Users Service.
I believe this would be the one of the better ways to implement security for microservice architecture.
Please suggest if there is any more elegant way.
Thanks In Advance.