ACL
An access control list connected to a database via knex module.
How to install
npm install --save drone-acl
How to use
const ACL = ;const knex = ; { const knexConn = ; const acl = knexConn; // run required database migrations await acl; // create a permission await aclpermissions; // create a role const admin = await aclroles; // if role is already created you can use: // const admin = acl.role('administrator'); // assign permissions to a role await admin; await admin; // true};
API
ACL
migrate(): Promise
Create required DB tables
acl;
role(name: String): RolePermission
Get a role to work with
const role = acl;
RolePermission
allow(permission: String|String[]): Promise
Add a permission or array of permissions to the role access
acl;
disallow(permission: String|String[]): Promise
Remove permission or array of permissions from the role access
acl;
hasPermission(permission: String): Promise -> boolean
Verifiy if role has access to the permission
acl;
can(permission: String): Promise -> boolean
Alias of hasPermission()
acl;
Roles
create(name): Promise -> RolePermission
Create a new role
aclroles;
update(name, changes): Promise
Update a role data
aclroles;
delete(name): Promise
Delete a role by its name
aclroles;
findByName(name): Promise
Find a role by its name
aclroles;
list(): Promise
List all available roles
aclroles;
clear(): Promise
Remove all roles
aclrolesclear;
Permissions
create(name): Promise
Create a new permission
aclpermissions;
update(name, changes): Promise
Update a permission data
aclpermissions;
delete(name): Promise
Delete a permission by its name
aclpermissions;
findByName(name): Promise
Find a permission by its name
aclpermissions;
list(): Promise
List all available permissions
aclpermissions;
clear(): Promise
Remove all permissions
aclpermissionsclear;