Comparing version
{ | ||
"name": "role-acl", | ||
"version": "3.2.2", | ||
"version": "3.3.0", | ||
"description": "Role, Attribute and Condition based Access Control for Node.js", | ||
@@ -66,2 +66,3 @@ "main": "./index.js", | ||
"dependencies": { | ||
"jsonpath-plus": "^0.18.0", | ||
"matcher": "^1.0.0", | ||
@@ -68,0 +69,0 @@ "notation": "^1.3.5" |
@@ -80,2 +80,27 @@ [](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=73QY55FZWSPRJ) [](https://travis-ci.org/tensult/role-acl) [](https://codeclimate.com/github/tensult/role-acl/test_coverage) [](https://npmjs.org/package/role-acl) [](https://github.com/tensult/role-acl/issues) | ||
// Condition with dynamic context values using JSONPath | ||
// We can use this to allow only owner of the article to edit it | ||
ac.grant('user').condition( | ||
{ | ||
Fn: 'EQUALS', | ||
args: { | ||
'requester': '$.owner' | ||
} | ||
}).execute('edit').on('article'); | ||
permission = ac.can('user').context({ requester: 'dilip', owner: 'dilip' }).execute('edit').on('article'); | ||
console.log(permission.granted); // —> true | ||
// We can use this to prevent someone to approve their own article so that it goes to review by someone before publishing | ||
ac.grant('user').condition( | ||
{ | ||
Fn: 'NOT_EQUALS', | ||
args: { | ||
'requester': '$.owner' | ||
} | ||
}).execute('approve').on('article'); | ||
permission = ac.can('user').context({ requester: 'dilip', owner: 'dilip' }).execute('approve').on('article'); | ||
console.log(permission.granted); // —> false | ||
// Using custom/own condition functions | ||
@@ -82,0 +107,0 @@ ac.grant('user').condition( |
Deprecated
MaintenanceThe maintainer of the package marked it as deprecated. This could indicate that a single version should not be used, or that the package is no longer maintained and any new vulnerabilities will not be fixed.
Found 1 instance in 1 package
120862
0.76%443
5.98%3
50%1
Infinity%+ Added
+ Added