Authentication for Microservices #4103
Replies: 2 comments 1 reply
-
When developing microservices with AdonisJS, authentication is an important issue to consider. As you mentioned, if you maintain an authentication database for each microservice, it can lead to issues with data synchronization and maintaining multiple data sources. On the other hand, if you have a single authentication service for all microservices, there can be a performance bottleneck and the system can be difficult to scale. An alternative approach is to use a third-party authentication provider, such as Auth0, which can handle authentication and authorization across all microservices. Auth0 uses a JWT (JSON Web Token) token template that is issued by the authentication service and includes information about the authenticated user. Each microservice can check the validity of the token and obtain information about the user without having to make a database call. If you want to keep the authentication service on your own system, another approach is to use an authentication protocol like OAuth2. In this model, the authentication service issues an access token that can be used in other microservices to authenticate the user. The access token contains enough information to verify the user's authenticity without having to access the authentication database. Additionally, you can use Redis or another in-memory database to store user information after authentication. This can reduce authentication server overhead and speed up access to user data by other microservices. In summary, there are several approaches you can consider when implementing authentication in microservices with AdonisJS. It's important to find the solution that best fits your system's needs and offers a good mix of performance, security, and ease of maintenance. |
Beta Was this translation helpful? Give feedback.
-
Eu tinha esquecido desse topico, eu resolvi meu problema da seguinte forma:
To generate the token
To decrypt the token, i put this logic in a middleware.
|
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
I am planning on developing microservices with Adonisjs
But I am confused how authetication will work.
Since authetication service will have it's own database, How I am supposed to pass authetication data to another service without access authentication database or I must maintain a connection to authetication datbase from each microservice ?
As soon as I use auth middleware, There will be a database call to fetch user data based on token, How can I get data in that case ? Shall I modify auth middleware to call authentication service(Seems a like there will be a lot of load on authentication server).
Please share your ideas/Suggestions
Beta Was this translation helpful? Give feedback.
All reactions