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?
@WangLarry
Yes, I have written a test case for the same: https://github.com/tensult/role-acl/blob/develop/test/acl.spec.ts#L1823
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.
https://www.npmjs.com/package/role-acl/v/4.4.1
@n8sabes released to npm.
YAYY!! It works perfectly!!
@koladilip, Thank you for this awesome library and continued effort to make it better.
I'll close the Issue out.