Skip to content

Authentication and Authorization library using the Identity Provider module based on the MS (Module Standard)

License

Notifications You must be signed in to change notification settings

FirstLegoLeague/ms-auth

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

npm codecov Build status GitHub

David Dependency Status David Dev Dependency Status David Peer Dependencies Status

FIRST LEGO League Authentication & Authorization

Authentication and Authorization package for interacting with the IdP (Identity Provider) module, working according to the FIRST LEGO League TMS Module Standard authentication section.

Logic

This package contains several middlewares, each with a specific function:

  • The Autentication middleware: redirects to the IdP if the user data is not saved, and save the data to the request. Also recieves the data from the IdP.
  • The Authorization middleware: sends status 403 if the user is not in the givven array parameter.
  • The Development Autentication middleware: saves a fake username data to the request, as if the IdP did it.

Usage

The package has several routers for different tasks.

Authentication

Meant only to identify the user. If the user has no identification, it redirects them to the Identity Provider service:

const Router = require('router')
const { authenticationMiddleware } = require('@first-lego-league/ms-auth')

const router = new Router()
router.use(authenticationMiddleware)

If you want a development version, which will not send you to the IdP, use:

const Router = require('router')
const { authenticationDevMiddleware } = require('@first-lego-league/ms-auth')

const router = new Router()
router.use(authenticationDevMiddleware('username'))

Where the username is the identification of the user, no matter what.

Autorization

Meant to define which roles can access each route:

const Router = require('router')
const { authorizationMiddleware } = require('@first-lego-league/ms-auth')

const router = new Router()
router.use('some_route', authorizationMiddleware(['roles', 'that', 'can', 'use', 'this', 'route']))

Contribution

To contribute to this repository, simply create a PR and set one of the Code Owners to be a reviewer. Please notice the linting and UT, because they block merge. Keep the package lightweight and easy to use. Thank you for contributing!

About

Authentication and Authorization library using the Identity Provider module based on the MS (Module Standard)

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published