@first-lego-league/ms-auth

A package for a generic Service Provider using JWT

Stats

StarsIssuesVersionUpdatedCreatedSize
@first-lego-league/ms-auth
001.4.32 years ago3 years agoMinified + gzip package size for @first-lego-league/ms-auth in KB

Readme

npm David Dependency Status David Dev Dependency Status David Peer Dependencies Status Build status GitHub

FIRST LEGO League Authentication & Authorization

Authentication and Authorization library using the Identity Provider module based on the FIRST LEGO League TMS Module Standard.

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!

If you find any bugs or have a feature request, please open an issue on github!

The npm package download data comes from npm's download counts api and package details come from npms.io.