Skip to content

Fully-tested AccessControl implementation written in TypeScript

License

Notifications You must be signed in to change notification settings

EndemolShineGroup/acl

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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