Skip to content
This repository has been archived by the owner on Dec 16, 2022. It is now read-only.

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:

  1. Client Redirects user to /login/{provider}?return={returnUrl}
  2. PassportJS resolves the provider, sets the returnUrl in session and redirects to the Provider site along with the required request tokens
  3. After user authorises the App on the provider, the provider redirects back to the server with a token
  4. Gateway decodes the token and retrieves user information using it
  5. If the user is non-existent, it will save the generic user details in the DB
  6. The user details are encoded in a token and saved to the session, with an expiry time of 1 day
  7. After completion the user is redirected back to the returnUrl saved in the session
  8. The cookie gets sent in every subsequent request and user is identified using this session cookie
  9. On logout the cookie, the browser cookie is reset.