Skip to content

Latest commit

 

History

History
77 lines (53 loc) · 2.42 KB

File metadata and controls

77 lines (53 loc) · 2.42 KB

EX-4 - Using Auth Frameworks

In this exercise we will explore authn and authz frameworks.

Our app will list the context of your inbox. A web page is presented, when show inbox is selected the app will trigger a authorization code grant flow and list content of the inbox. This version of the app uses the Microsoft Authentication Library (MSAL) - the NodeJS version.

Outline


Architecture

NodeJS based backend, simple html on front end. SSO using oauth with Microsoft Entra ID

Important NodeJS modules

  • Fastify - web server framework
  • Handlebars - templating language
  • Got - http request library
  • Pino - NodeJs logger
  • Tap - Test framework for JS
  • Sinon - Test spies, stubs and mocks for JS
  • MSAL for Node - Microsoft Auth library for Node

Requirements

Install

npm install

Test

npm test

Config

Expects the following environment variables to execute properly

export NODE_ENV=production
export CLIENT_SECRET=''
export CLIENT_ID=""
export TENANT_ID=""
export PORT=3000
export REDIRECT_URI=https://...../callback

Run

npm start

NPM Scripts

  • npm test (execute unit tests)
  • npm run test-cover (run, reload on changes, show coverage)
  • npm run dev (run server, reload on changes)
  • npm run snyk (scan for open source vulnerabilities)

Keeping the dependencies up-to-date

To keep modules updated:

  • npm outdated (list outdated modules)
  • npm upgrade (upgrade minor versions of modules)
  • npm install @latest
    (remember to verify and execute test before major version updated, or in fact after any update)