casbin 5.13.1 → 5.13.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,3 +1,10 @@
1
+ ## [5.13.2](https://github.com/casbin/node-casbin/compare/v5.13.1...v5.13.2) (2022-03-02)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * *matcher result should be boolean or number* for KeyGet2 ([#347](https://github.com/casbin/node-casbin/issues/347)) ([0257078](https://github.com/casbin/node-casbin/commit/0257078e1302f5ef081ec143afe5c470f4f862e9))
7
+
1
8
  ## [5.13.1](https://github.com/casbin/node-casbin/compare/v5.13.0...v5.13.1) (2022-02-22)
2
9
 
3
10
 
@@ -0,0 +1,11 @@
1
+ [request_definition]
2
+ r = sub, obj
3
+
4
+ [policy_definition]
5
+ p = sub, obj
6
+
7
+ [policy_effect]
8
+ e = some(where (p.eft == allow))
9
+
10
+ [matchers]
11
+ m = keyGet2(r.obj, p.obj, 'id')
@@ -0,0 +1 @@
1
+ p, alice, /data/:id
@@ -387,8 +387,16 @@ class CoreEnforcer {
387
387
  eftRes = result;
388
388
  }
389
389
  break;
390
+ case 'string':
391
+ if (result === '') {
392
+ eftRes = effect_1.Effect.Indeterminate;
393
+ }
394
+ else {
395
+ eftRes = effect_1.Effect.Allow;
396
+ }
397
+ break;
390
398
  default:
391
- throw new Error('matcher result should be boolean or number');
399
+ throw new Error('matcher result should only be of type boolean, number, or string');
392
400
  }
393
401
  const eft = parameters['p_eft'];
394
402
  if (eft && eftRes === effect_1.Effect.Allow) {
@@ -384,8 +384,16 @@ export class CoreEnforcer {
384
384
  eftRes = result;
385
385
  }
386
386
  break;
387
+ case 'string':
388
+ if (result === '') {
389
+ eftRes = Effect.Indeterminate;
390
+ }
391
+ else {
392
+ eftRes = Effect.Allow;
393
+ }
394
+ break;
387
395
  default:
388
- throw new Error('matcher result should be boolean or number');
396
+ throw new Error('matcher result should only be of type boolean, number, or string');
389
397
  }
390
398
  const eft = parameters['p_eft'];
391
399
  if (eft && eftRes === Effect.Allow) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "casbin",
3
- "version": "5.13.1",
3
+ "version": "5.13.2",
4
4
  "description": "An authorization library that supports access control models like ACL, RBAC, ABAC in Node.JS",
5
5
  "main": "lib/cjs/index.js",
6
6
  "typings": "lib/cjs/index.d.ts",