How to expose authentication microservice to other microservices in nestjs graphql (code-first) federation?

60 Views Asked by At

I've been searching on tutorial or document to follow how to implement right authentication in nestjs graphql federation I found two option :

  1. Create auth module in user microservice and in every microservice i duplicate the code
  2. Create auth in shared module and call it in other microservices

For the first option i think in duplicating code is not the best practice, for the second option i think that i need to expose user microservice data to other microservice that leads me to the first option which is duplicating the code

Questions

  • What is the best practice i need to use ?
  • how to let other microservices works with auth module like guards token data etc ...

I tried a lot of example but no result since i don't understand the phenomen correctly

0

There are 0 best solutions below