Reputation: 387
I am currently playing with NestJS' microservices and authentication, and I am facing a problem for which I don't have a clear solution.
Let's imagine I have an API gateway balancing the calls to multiple microservices. I would like to enable authentication (via JWT tokens) and retreive the user information for every process I might call on any microservice.
The problem I am facing is that I don't know where to decode the token.
I feel confident implementing both of them, I just cannot figure out if they are good practicesor if there is a better solution I haven't thought of yet.
Upvotes: 4
Views: 5138
Reputation: 2383
The best way to do this by use the flow in below.
x-user-id
, x-user-name
, x-user-email
. and call microservice-x.Lets say microservice-x will create and record in table then call microservice-z to send email.
x-user-id
. then call microservice-z to send email by x-user-email
.Upvotes: 7