casbin 5.20.3 → 5.21.0
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 +14 -0
- package/lib/cjs/coreEnforcer.d.ts +7 -0
- package/lib/cjs/coreEnforcer.js +9 -0
- package/lib/cjs/frontend.js +10 -4
- package/lib/esm/coreEnforcer.d.ts +7 -0
- package/lib/esm/coreEnforcer.js +9 -0
- package/lib/esm/frontend.js +10 -4
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,17 @@
|
|
|
1
|
+
# [5.21.0](https://github.com/casbin/node-casbin/compare/v5.20.4...v5.21.0) (2023-01-21)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Features
|
|
5
|
+
|
|
6
|
+
* support setNamedRoleManager() ([#416](https://github.com/casbin/node-casbin/issues/416)) ([869e8f9](https://github.com/casbin/node-casbin/commit/869e8f989b899073e071fa90777584f12cde0856))
|
|
7
|
+
|
|
8
|
+
## [5.20.4](https://github.com/casbin/node-casbin/compare/v5.20.3...v5.20.4) (2023-01-20)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Bug Fixes
|
|
12
|
+
|
|
13
|
+
* add groupPolicy for GetPermissionForUser in frontend.ts ([#415](https://github.com/casbin/node-casbin/issues/415)) ([5d1a679](https://github.com/casbin/node-casbin/commit/5d1a6795f94af487218f10dce85fe191fb0dea37))
|
|
14
|
+
|
|
1
15
|
## [5.20.3](https://github.com/casbin/node-casbin/compare/v5.20.2...v5.20.3) (2023-01-10)
|
|
2
16
|
|
|
3
17
|
|
|
@@ -69,6 +69,13 @@ export declare class CoreEnforcer {
|
|
|
69
69
|
* @param rm the role manager.
|
|
70
70
|
*/
|
|
71
71
|
setRoleManager(rm: RoleManager): void;
|
|
72
|
+
/**
|
|
73
|
+
* setRoleManager sets the role manager for the named policy.
|
|
74
|
+
*
|
|
75
|
+
* @param ptype the named policy.
|
|
76
|
+
* @param rm the role manager.
|
|
77
|
+
*/
|
|
78
|
+
setNamedRoleManager(ptype: string, rm: RoleManager): void;
|
|
72
79
|
/**
|
|
73
80
|
* getRoleManager gets the current role manager.
|
|
74
81
|
*/
|
package/lib/cjs/coreEnforcer.js
CHANGED
|
@@ -113,6 +113,15 @@ class CoreEnforcer {
|
|
|
113
113
|
setRoleManager(rm) {
|
|
114
114
|
this.rmMap.set('g', rm);
|
|
115
115
|
}
|
|
116
|
+
/**
|
|
117
|
+
* setRoleManager sets the role manager for the named policy.
|
|
118
|
+
*
|
|
119
|
+
* @param ptype the named policy.
|
|
120
|
+
* @param rm the role manager.
|
|
121
|
+
*/
|
|
122
|
+
setNamedRoleManager(ptype, rm) {
|
|
123
|
+
this.rmMap.set(ptype, rm);
|
|
124
|
+
}
|
|
116
125
|
/**
|
|
117
126
|
* getRoleManager gets the current role manager.
|
|
118
127
|
*/
|
package/lib/cjs/frontend.js
CHANGED
|
@@ -14,6 +14,7 @@
|
|
|
14
14
|
// limitations under the License.
|
|
15
15
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
16
|
exports.casbinJsGetPermissionForUser = void 0;
|
|
17
|
+
const lodash_1 = require("lodash");
|
|
17
18
|
const util_1 = require("./util");
|
|
18
19
|
/**
|
|
19
20
|
* Experiment!
|
|
@@ -40,10 +41,15 @@ async function casbinJsGetPermissionForUser(e, user) {
|
|
|
40
41
|
s += '[matchers]\n';
|
|
41
42
|
s += `m = ${(_l = (_k = m.get('m')) === null || _k === void 0 ? void 0 : _k.get('m')) === null || _l === void 0 ? void 0 : _l.value.replace(/_/g, '.')}`;
|
|
42
43
|
obj['m'] = s;
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
44
|
+
const policy = util_1.deepCopy(await e.getPolicy());
|
|
45
|
+
const groupPolicy = util_1.deepCopy(await e.getGroupingPolicy());
|
|
46
|
+
policy.forEach((item) => {
|
|
47
|
+
item.unshift('p');
|
|
48
|
+
});
|
|
49
|
+
groupPolicy.forEach((item) => {
|
|
50
|
+
item.unshift('g');
|
|
51
|
+
});
|
|
52
|
+
obj['p'] = lodash_1.concat(policy, groupPolicy);
|
|
47
53
|
return JSON.stringify(obj);
|
|
48
54
|
}
|
|
49
55
|
exports.casbinJsGetPermissionForUser = casbinJsGetPermissionForUser;
|
|
@@ -69,6 +69,13 @@ export declare class CoreEnforcer {
|
|
|
69
69
|
* @param rm the role manager.
|
|
70
70
|
*/
|
|
71
71
|
setRoleManager(rm: RoleManager): void;
|
|
72
|
+
/**
|
|
73
|
+
* setRoleManager sets the role manager for the named policy.
|
|
74
|
+
*
|
|
75
|
+
* @param ptype the named policy.
|
|
76
|
+
* @param rm the role manager.
|
|
77
|
+
*/
|
|
78
|
+
setNamedRoleManager(ptype: string, rm: RoleManager): void;
|
|
72
79
|
/**
|
|
73
80
|
* getRoleManager gets the current role manager.
|
|
74
81
|
*/
|
package/lib/esm/coreEnforcer.js
CHANGED
|
@@ -110,6 +110,15 @@ export class CoreEnforcer {
|
|
|
110
110
|
setRoleManager(rm) {
|
|
111
111
|
this.rmMap.set('g', rm);
|
|
112
112
|
}
|
|
113
|
+
/**
|
|
114
|
+
* setRoleManager sets the role manager for the named policy.
|
|
115
|
+
*
|
|
116
|
+
* @param ptype the named policy.
|
|
117
|
+
* @param rm the role manager.
|
|
118
|
+
*/
|
|
119
|
+
setNamedRoleManager(ptype, rm) {
|
|
120
|
+
this.rmMap.set(ptype, rm);
|
|
121
|
+
}
|
|
113
122
|
/**
|
|
114
123
|
* getRoleManager gets the current role manager.
|
|
115
124
|
*/
|
package/lib/esm/frontend.js
CHANGED
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
12
|
// See the License for the specific language governing permissions and
|
|
13
13
|
// limitations under the License.
|
|
14
|
+
import { concat } from 'lodash';
|
|
14
15
|
import { deepCopy } from './util';
|
|
15
16
|
/**
|
|
16
17
|
* Experiment!
|
|
@@ -37,9 +38,14 @@ export async function casbinJsGetPermissionForUser(e, user) {
|
|
|
37
38
|
s += '[matchers]\n';
|
|
38
39
|
s += `m = ${(_l = (_k = m.get('m')) === null || _k === void 0 ? void 0 : _k.get('m')) === null || _l === void 0 ? void 0 : _l.value.replace(/_/g, '.')}`;
|
|
39
40
|
obj['m'] = s;
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
41
|
+
const policy = deepCopy(await e.getPolicy());
|
|
42
|
+
const groupPolicy = deepCopy(await e.getGroupingPolicy());
|
|
43
|
+
policy.forEach((item) => {
|
|
44
|
+
item.unshift('p');
|
|
45
|
+
});
|
|
46
|
+
groupPolicy.forEach((item) => {
|
|
47
|
+
item.unshift('g');
|
|
48
|
+
});
|
|
49
|
+
obj['p'] = concat(policy, groupPolicy);
|
|
44
50
|
return JSON.stringify(obj);
|
|
45
51
|
}
|
package/package.json
CHANGED