New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

access-roles

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

access-roles

# HOW TO INSTALL ?

latest
Source
npmnpm
Version
1.0.3
Version published
Maintainers
1
Created
Source

Node ACCESS ROLES

HOW TO INSTALL ?

npm install --save access-roles

HOW TO USE ?

var accessRoles = require('access-roles')(app);

accessRoles(options, callback)

Create a new accessRoles middleware function using the given options object and callback function.

options

  • roles (Required) Filename contains roles array:

    • path (Required): Handled by express.
    • methods (Default: ['GET']): HTTP methods array.
    • permissions (Required): Permissions allowed.
    • redirect Redirect a request, handled by express.
  • dataSource (Required) Object in req contains user info.

  • onSuccess Response on success.

  • onFailed Response on failed (Default: { status: 401, message: 'Not Authorized' }).

  • beforeEnter Called before enter.

  • callback The callback(err[name, message]).

Example

{
    "roles": [
        {
            "path": "/",
            "methods": ["GET"],
            "permissions": ["Admin"],
            "redirect": "/home"
        }
    ]
}
function onSuccess(req, res, next) {
	// ...
}

function onFailed(req, res, next) {
	// ...
}

function beforeEnter(req, res, next) {
	// req.userData = ...;
}

var options = {
    roles: './config/roles.json',
    dataSource: 'userData',
    onSuccess: onSuccess,
    onFailed: onFailed,
    beforeEnter: beforeEnter
};
accessRoles(options, (err) => {
	if (err) throw err;
});

TODO

  • Tests
  • Give me suggestions ??

LICENSE

GPL-3.0

Keywords

access

FAQs

Package last updated on 26 May 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts