InterviewSolution
| 1. |
How would you implement authentication in microservice architecture? |
|
Answer» There are mainly two WAYS to achieve AUTHENTICATION in microservices architecture.
All the microservices can use a CENTRAL session store and user authentication can be achieved. This approach works but has many drawbacks as well. Also, the centralized session store should be protected and services should connect securely. The application needs to manage the state of the user, so it is called stateful session.
In this approach, unlike the traditional way, information in the form of token is held by the clients and the token is passed along with each request. A server can check the token and verify the VALIDITY of the token like expiry, etc. Once the token is validated, the IDENTITY of the user can be obtained from the token. However, encryption is required for security reasons. JWT(JSON web token) is the new open standard for this, which is widely used. Mainly used in stateless applications. Or, you can use OAuth based authentication mechanisms as well. |
|