express-header-authorize

1.0.4 • Public • Published

express-header-authorize

This module provides the express header authorize with basic auth and OIDC accesstoken.

Install

$ npm install express-header-authorize

Usage

Example

import Authorize from 'express-header-authorize';

const authorize = new Authorize({
  accesstokenConfig: {
    url: <OIDC introspection url>,
    clientId: <OIDC client ID>,
    clientSecret: <OIDC client Secret>,
  },
  ldapConfig: {
    url: <LDAP url (ldaps://ldap.com:636)>,
    searchBase: <LDAP searchBase (ou=ldap,o=ldap.com))>,
    searchFilter: <LDAP searchFilter (mail={{username}})>,
  },
});

// authorize with basic auth header
authorize.authorizeWithBasicAuth('Basic XXXX')
.then((user) => {
  if(user.active) {
    // user authorize passed
  } else {
    // user authorize failed
  }
});

// authorize with accesstoken
authorize.authorizeWithAccesstoken('XXXXXXXXXX')
.then((user) => {
  if(user.active) {
    // user authorize passed
  } else {
    // user authorize failed
  }
});

// authorize with header
authorize.authorizeWithHeader(header)
.then((user) => {
  if(user.active) {
    // user authorize passed
  } else {
    // user authorize failed
  }
});

/express-header-authorize/

    Package Sidebar

    Install

    npm i express-header-authorize

    Weekly Downloads

    6

    Version

    1.0.4

    License

    MIT

    Unpacked Size

    20.7 kB

    Total Files

    11

    Last publish

    Collaborators

    • yanlianggu