2.0.0 • Published 5 years ago

@endemolshinegroup/acl v2.0.0

Weekly downloads
1
License
MIT
Repository
github
Last release
5 years ago

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);