Skip to content

Latest commit

 

History

History
76 lines (54 loc) · 2.08 KB

README.md

File metadata and controls

76 lines (54 loc) · 2.08 KB

Auth Service

The main function of the Auth service is to provide functionalites of Sign Up, Sign In and Sign Out.

There are two ways of implementing authentication :

  • Stateful authentication using sessions.
  • Stateless authentication using signed token.

Stateless Authentication is used to make it scalable.

JWT (JSON Web Token) are sent as a cookie to the clients so that their further requests could be authorized.

Database (authUser)

Although noSQL database is used but a proper Schema is maintained.

UserCollection


Attribute Type Description
_id ObjectId unique object id of a user (Primary Key)
email string email id of user
userName string unique userName of user
password string password of user
isAuth boolean If spotify has been authorized or not

API Reference

Registers a new user, and sends a UserCreatedEvent .

  POST /api/auth/signup


Signs in a user, by sending a JWT as a cookie to the client.

  POST /api/auth/signin


Logs out the user by removing the cookie.

  POST /api/auth/signin

Events

UserCreatedEvent

It is fired whenever a new user signs up .

Attribute Type Description
userId string _id of UserCollection
email string email id of user
userName string unique userName of user

Handlers

Handlers consumes events from NATS stream and processes them.

It captures the UserAuthorized Event and processes it and makes isAuth field of UserCollection true.


Architecture Diagram

auth