You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Dec 12, 2020. It is now read-only.
- You can specify dynamic context values in the conditions using JSON Paths.
25
-
- You can define your own condition functions too but please note if you use custom functions instead of standard conditions, you won't be able to save them as json in the DB.
- You can specify dynamic context values in the core conditions using JSON Paths.
25
+
- Supports your own custom conditions e.g. `custom:isArticleOwner`.
26
+
- You can define your own function conditions too but please note if you use custom functions instead of standard conditions, you won't be able to save them as json in the DB.
26
27
- Policies are JSON compatible so can be stored and retrieved from database.
27
28
- Fast. (Grants are stored in memory, no database queries.)
You can declare your own conditions (**requires version >= 4.5.2**). Those declarations should be registerd with the library BEFORE your grants and permission checks. The custom condition declarations are allowing you to extend the library core conditions with your own business logic without sacrificing the abillity to serialize your grants.
**Custom conditions allow security policy serializing and can be registered while initializing (in batch):**
224
+
225
+
> NOTE: function conditions are not serializeable, so custom conditions are the recommended way to implement your permission policy. You can easiely convert your current function conditions to custom conditions.
226
+
227
+
```js
228
+
constmyPolicy= {
229
+
// Serialized policy, can be stored in file, DB, etc
230
+
grants: [
231
+
{
232
+
role:'user',
233
+
resource:'profile',
234
+
action: ['delete', 'update'],
235
+
attributes: ['*'],
236
+
condition: {
237
+
Fn:'custom:isResourceOwner',
238
+
args: { resource:'profile' }
239
+
}
240
+
},
241
+
{
242
+
role:'user',
243
+
resource:'article',
244
+
action: ['delete', 'update'],
245
+
attributes: ['*'],
246
+
condition: {
247
+
Fn:'custom:isResourceOwner',
248
+
args: { resource:'article' }
249
+
}
250
+
},
251
+
],
252
+
// Map your custom conditions to the serialized policy
0 commit comments