This repository has been archived by the owner on Dec 16, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
Backend Gateway
Rupesh Parab edited this page Oct 22, 2019
·
1 revision
To help with authentication a new layer of gateway has been introduced between the Client and the Server. This gateway is developed using Express (Node.js) and PassportJS
Gateway connects to the same DB as the server and has uses a new set of tables for User Management. OAuth Provider specific strategies have been used in PassportJS to authenticate users using their Identity from OAuth Providers like Google and Azure.
This is the general OAuth Flow starting from Client:
- Client Redirects user to /login/{provider}?return={returnUrl}
- PassportJS resolves the provider, sets the returnUrl in session and redirects to the Provider site along with the required request tokens
- After user authorises the App on the provider, the provider redirects back to the server with a token
- Gateway decodes the token and retrieves user information using it
- If the user is non-existent, it will save the generic user details in the DB
- The user details are encoded in a token and saved to the session, with an expiry time of 1 day
- After completion the user is redirected back to the returnUrl saved in the session
- The cookie gets sent in every subsequent request and user is identified using this session cookie
- On logout the cookie, the browser cookie is reset.