r/elixir • u/Academic_Fudge1540 • 22d ago
Micro services architecture how do I pass the user authentication between services
Or user authentication only to the front end application?
4
Upvotes
r/elixir • u/Academic_Fudge1540 • 22d ago
Or user authentication only to the front end application?
11
u/boredsoftwareguy 22d ago
You could use JWTs with the appropriate user claims.
3
u/Agile_Use_1768 21d ago
Look inside the OAuth protocol. You would essentially act as the authentication and authorization provider.
One service will take care of authentication (internal user and password or social login, etc), session management, and providing each client (microservice) a public key to work with your tokens, it is the Auth server.
Each microservice will validate against the provided key if the token is valid and will define internal scopes ie this user can or cannot do such thing elixir has a bodyguard library for this and it is excellent!
If you need chained microservice calls you would usually pass token within the X-Authorization header.
This is a shallow implementation, a more robust implementation usually requires session mutation lists (in case you ban a user it prevents the young token to pass authorization checks) and or authoritative active session checks for simplicity
1
u/SpiralCenter 16d ago
A token, most likely encrypted and signed. JWT is a standard a lot of people use.