tensult / role-acl

Role based access control using actions, attributes and sync and async conditions

Home Page:https://www.tensult.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Extend Role in Array

n8sabes opened this issue · comments

Is it possible to extend a role via the Array Syntax when loading from a DB? I am not able to find anything in the docs if this is possible and seems quite useful.

For example ('admin' extends 'user'):

let grantList = [
    { role: 'user', resource: 'video', action: 'create', attributes: ['*'] },
    { role: 'user', resource: 'video', action: 'read', attributes: ['*'] },
    { role: 'user', resource: 'video', action: 'update', attributes: ['*'] },

    { role: 'admin', extend: 'user' },
    { role: 'admin', resource: 'video', action: 'delete', attributes: ['*'] },
];

After extending a role, change permissions of original role, the extended role can reflect this change?

Is it possible to extend a role via the Array Syntax when loading from a DB? I am not able to find anything in the docs if this is possible and seems quite useful.

For example ('admin' extends 'user'):

let grantList = [
    { role: 'user', resource: 'video', action: 'create', attributes: ['*'] },
    { role: 'user', resource: 'video', action: 'read', attributes: ['*'] },
    { role: 'user', resource: 'video', action: 'update', attributes: ['*'] },

    { role: 'admin', extend: 'user' },
    { role: 'admin', resource: 'video', action: 'delete', attributes: ['*'] },
];

https://github.com/tensult/role-acl/blob/develop/test/acl.spec.ts#L243 I have implemented this, please check.

@koladilip Cool, thanks for your great library.

@WangLarry Thanks!! Please share it with your friends :)

@koladilip, Thanks so much for adding DB support for extend!

As it's not yet on a released version, how can it be installed into an existing project from the develop branch? I've tried yarn add https://github.com/tensult/role-acl.git#develop but it appears to result in an incomplete install.

YAYY!! It works perfectly!!

@koladilip, Thank you for this awesome library and continued effort to make it better.

I'll close the Issue out.