Serendipity2-0 / TradeManV1

1 stars 0 forks source link

V1 Authentication #46

Open srijan-11 opened 4 months ago

srijan-11 commented 4 months ago

Creating login functionality in FastAPI

  1. DB to store username and hash password We already have firebase db, we can store the hash passwords in it.
  2. Password Hashing use passlib library to hash the passwords.
  3. JWT for authentication A jwt token will be created (with a secret code) once the user is validated. The secret token will be common for all the users. With every api call this jwt token needs to be sent to backend and the backend will validate the token (with the secret code) and the api logic will work. the jwt token will contain the username and the expiry of the token. If the token is expired the the api will return 403 error
  4. Access Token and Refresh Token while the password is validated the api will return 2 tokens
  1. Access Token: this token has smaller expiry time - 30 minutes - will be a jwt bearer token
  2. Refresh Token: This token has large expiry time - 1 day, provide new access token with this refresh token. Store it in db and backlist once the user logs out.
  3. middleware to authenticate the token for every api call Every backend call needs to be authenticated before serving the request. The user needs to be verified from the jwt token, to know if the operation is allowed for the user or not.
amolkittur commented 2 months ago

@satyarth12 We need to implement keycloak authentication for the login functionality. We will have a meeting once with srijan and code he has developed in his private repo.

satyarth12 commented 2 months ago

@satyarth12 We need to implement keycloak authentication for the login functionality. We will have a meeting once with srijan and code he has developed in his private repo.

Can you ask srijan to push it in serendipity org?

satyarth12 commented 2 months ago

@amolkittur @omkarh25 I'm discarding Srijan's code due to very less visibility & communication of the keycloak implementation.

Will utilise today's day to implement our own structure.