Previously in our monolithic application, we have used @nestjs/passport with cognito for authentication and used guards (CognitoGuard) and decorators (CurrentUser) across the application.
Folder structure is like
src
--auth (JWT)
--aws (Cognito, S3, SSM)
--db (mongo)
--user
--hospital
--clinical
Now, We have moved to microservice architecture. So there are three services called UserService (signin and basic user routes), HospitalService and ClinicalService. Each service will be in different repositories, and there will be role-based access too.
Here is the question:
How to implement authentication flow and share user data with all the services?
How can we construct the services?
Do we have to Repeat the same code in each repo?
There will be AWS services like Cognito, S3, SSM, and SES as well and It'll be common to all the services.
Api is REST