@endemolshinegroup/acl
TypeScript icon, indicating that this package has built-in type declarations

2.0.0 • Public • Published

Banner

MIT Licensed NPM Version Build Status Greenkeeper Status

Code Issues Codebase Maintainability Test Coverage Jest

Commitizen Semantic Release Prettier

An Access Control library for multi-tenant systems

Installation

yarn add @endemolshinegroup/acl

Usage

import AccessControl from '@endemolshinegroup/acl';

const roles = {
  User: {
    GetUsers: {
      dev: true,
      staging: false,
      prod: false,
    }
  }
}

// Create an instance of AccessControl
const ac = new AccessControl(rolesObj);
// you can also do the following at any time
ac.setRoles(rolesObj);

// Checking permissions
ac.does(`${role}`).havePermission(`${permission}`).for(`${stage}`); // true

// Granting a permission
ac.grant(`${role}`).permission(`${permission}`).for(`${stage[]}`);

// Denying a permission
ac.deny(`${role}`).permission(`${permission}`).for(`${stage[]}`);

// Extending permission
ac.allow(`${role}`).toExtend(`${role2}`);

// Removing role
ac.remove(`${role}`);

// Retrieving roles
ac.getRoles();

// Retrieving a list of role names
ac.getRolesList();

// Retrieving permissions for role
ac.getPermissions(role: string);

Readme

Keywords

none

Package Sidebar

Install

npm i @endemolshinegroup/acl

Weekly Downloads

0

Version

2.0.0

License

MIT

Unpacked Size

401 kB

Total Files

92

Last publish

Collaborators

  • hassankhan
  • endemolshinegroupbot