@nocobase/acl 0.7.0-alpha.4 → 0.7.0-alpha.56
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/lib/acl-available-action.js +14 -7
- package/lib/acl-available-strategy.js +108 -59
- package/lib/acl-resource.js +56 -40
- package/lib/acl-role.js +152 -80
- package/lib/acl.js +340 -189
- package/lib/allow-manager.js +123 -76
- package/lib/index.js +82 -18
- package/lib/skip-middleware.js +33 -24
- package/package.json +3 -8
- package/esm/acl-available-action.d.ts +0 -16
- package/esm/acl-available-action.js +0 -7
- package/esm/acl-available-action.js.map +0 -1
- package/esm/acl-available-strategy.d.ts +0 -29
- package/esm/acl-available-strategy.js +0 -60
- package/esm/acl-available-strategy.js.map +0 -1
- package/esm/acl-resource.d.ts +0 -25
- package/esm/acl-resource.js +0 -42
- package/esm/acl-resource.js.map +0 -1
- package/esm/acl-role.d.ts +0 -38
- package/esm/acl-role.js +0 -86
- package/esm/acl-role.js.map +0 -1
- package/esm/acl.d.ts +0 -64
- package/esm/acl.js +0 -202
- package/esm/acl.js.map +0 -1
- package/esm/allow-manager.d.ts +0 -13
- package/esm/allow-manager.js +0 -80
- package/esm/allow-manager.js.map +0 -1
- package/esm/index.d.ts +0 -6
- package/esm/index.js +0 -7
- package/esm/index.js.map +0 -1
- package/esm/skip-middleware.d.ts +0 -6
- package/esm/skip-middleware.js +0 -23
- package/esm/skip-middleware.js.map +0 -1
- package/lib/acl-available-action.js.map +0 -1
- package/lib/acl-available-strategy.js.map +0 -1
- package/lib/acl-resource.js.map +0 -1
- package/lib/acl-role.js.map +0 -1
- package/lib/acl.js.map +0 -1
- package/lib/allow-manager.js.map +0 -1
- package/lib/index.js.map +0 -1
- package/lib/skip-middleware.js.map +0 -1
- package/tsconfig.build.json +0 -9
|
@@ -1,11 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
3
6
|
exports.AclAvailableAction = void 0;
|
|
7
|
+
|
|
4
8
|
class AclAvailableAction {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
+
constructor(name, options) {
|
|
10
|
+
this.name = void 0;
|
|
11
|
+
this.options = void 0;
|
|
12
|
+
this.name = name;
|
|
13
|
+
this.options = options;
|
|
14
|
+
}
|
|
15
|
+
|
|
9
16
|
}
|
|
10
|
-
|
|
11
|
-
|
|
17
|
+
|
|
18
|
+
exports.AclAvailableAction = AclAvailableAction;
|
|
@@ -1,68 +1,117 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
exports.
|
|
7
|
-
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.predicate = exports.ACLAvailableStrategy = void 0;
|
|
7
|
+
exports.strategyValueMatched = strategyValueMatched;
|
|
8
|
+
|
|
9
|
+
function _lodash() {
|
|
10
|
+
const data = _interopRequireDefault(require("lodash"));
|
|
11
|
+
|
|
12
|
+
_lodash = function _lodash() {
|
|
13
|
+
return data;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
return data;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
20
|
+
|
|
21
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
22
|
+
|
|
23
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
24
|
+
|
|
25
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
26
|
+
|
|
27
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
28
|
+
|
|
29
|
+
function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
|
|
30
|
+
|
|
31
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
32
|
+
|
|
8
33
|
function strategyValueMatched(strategy, value) {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
return
|
|
34
|
+
if (strategy === '*') {
|
|
35
|
+
return true;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
if (_lodash().default.isString(strategy) && strategy === value) {
|
|
39
|
+
return true;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
if (_lodash().default.isArray(strategy) && strategy.includes(value)) {
|
|
43
|
+
return true;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
return false;
|
|
19
47
|
}
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
48
|
+
|
|
49
|
+
const predicate = {
|
|
50
|
+
own: {
|
|
51
|
+
filter: {
|
|
52
|
+
createdById: '{{ ctx.state.currentUser.id }}'
|
|
53
|
+
}
|
|
54
|
+
},
|
|
55
|
+
all: {}
|
|
28
56
|
};
|
|
57
|
+
exports.predicate = predicate;
|
|
58
|
+
|
|
29
59
|
class ACLAvailableStrategy {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
return carry;
|
|
43
|
-
}, {});
|
|
44
|
-
}
|
|
60
|
+
constructor(acl, options) {
|
|
61
|
+
this.acl = void 0;
|
|
62
|
+
this.options = void 0;
|
|
63
|
+
this.actionsAsObject = void 0;
|
|
64
|
+
this.allowConfigure = void 0;
|
|
65
|
+
this.acl = acl;
|
|
66
|
+
this.options = options;
|
|
67
|
+
this.allowConfigure = options.allowConfigure;
|
|
68
|
+
let actions = this.options.actions;
|
|
69
|
+
|
|
70
|
+
if (_lodash().default.isString(actions) && actions != '*') {
|
|
71
|
+
actions = [actions];
|
|
45
72
|
}
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
}
|
|
58
|
-
return false;
|
|
73
|
+
|
|
74
|
+
if (_lodash().default.isArray(actions)) {
|
|
75
|
+
this.actionsAsObject = actions.reduce((carry, action) => {
|
|
76
|
+
const _action$split = action.split(':'),
|
|
77
|
+
_action$split2 = _slicedToArray(_action$split, 2),
|
|
78
|
+
actionName = _action$split2[0],
|
|
79
|
+
predicate = _action$split2[1];
|
|
80
|
+
|
|
81
|
+
carry[actionName] = predicate;
|
|
82
|
+
return carry;
|
|
83
|
+
}, {});
|
|
59
84
|
}
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
matchAction(actionName) {
|
|
88
|
+
var _this$actionsAsObject;
|
|
89
|
+
|
|
90
|
+
if (this.options.actions == '*') {
|
|
91
|
+
return true;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
if ((_this$actionsAsObject = this.actionsAsObject) === null || _this$actionsAsObject === void 0 ? void 0 : _this$actionsAsObject.hasOwnProperty(actionName)) {
|
|
95
|
+
const predicateName = this.actionsAsObject[actionName];
|
|
96
|
+
|
|
97
|
+
if (predicateName) {
|
|
98
|
+
return predicate[predicateName];
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
return true;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
return false;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
allow(resourceName, actionName) {
|
|
108
|
+
if (this.acl.isConfigResource(resourceName) && this.allowConfigure) {
|
|
109
|
+
return true;
|
|
65
110
|
}
|
|
111
|
+
|
|
112
|
+
return this.matchAction(this.acl.resolveActionAlias(actionName));
|
|
113
|
+
}
|
|
114
|
+
|
|
66
115
|
}
|
|
67
|
-
|
|
68
|
-
|
|
116
|
+
|
|
117
|
+
exports.ACLAvailableStrategy = ACLAvailableStrategy;
|
package/lib/acl-resource.js
CHANGED
|
@@ -1,46 +1,62 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
3
6
|
exports.ACLResource = void 0;
|
|
7
|
+
|
|
4
8
|
class ACLResource {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
9
|
+
constructor(options) {
|
|
10
|
+
this.actions = new Map();
|
|
11
|
+
this.acl = void 0;
|
|
12
|
+
this.role = void 0;
|
|
13
|
+
this.name = void 0;
|
|
14
|
+
this.acl = options.role.acl;
|
|
15
|
+
this.role = options.role;
|
|
16
|
+
this.name = options.name;
|
|
17
|
+
const actionsOption = options.actions || {};
|
|
18
|
+
|
|
19
|
+
for (var _i = 0, _Object$keys = Object.keys(actionsOption); _i < _Object$keys.length; _i++) {
|
|
20
|
+
const actionName = _Object$keys[_i];
|
|
21
|
+
this.actions.set(actionName, actionsOption[actionName]);
|
|
14
22
|
}
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
getActions() {
|
|
26
|
+
return Array.from(this.actions.keys()).reduce((carry, key) => {
|
|
27
|
+
carry[key] = this.actions.get(key);
|
|
28
|
+
return carry;
|
|
29
|
+
}, {});
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
getAction(name) {
|
|
33
|
+
return this.actions.get(name) || this.actions.get(this.acl.resolveActionAlias(name));
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
setAction(name, params) {
|
|
37
|
+
const context = {
|
|
38
|
+
role: this.role,
|
|
39
|
+
acl: this.role.acl,
|
|
40
|
+
params: params || {},
|
|
41
|
+
path: `${this.name}:${name}`,
|
|
42
|
+
resourceName: this.name,
|
|
43
|
+
actionName: name
|
|
44
|
+
};
|
|
45
|
+
this.acl.emit('beforeGrantAction', context);
|
|
46
|
+
this.actions.set(name, context.params);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
setActions(actions) {
|
|
50
|
+
for (var _i2 = 0, _Object$keys2 = Object.keys(actions); _i2 < _Object$keys2.length; _i2++) {
|
|
51
|
+
const actionName = _Object$keys2[_i2];
|
|
52
|
+
this.setAction(actionName, actions[actionName]);
|
|
43
53
|
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
removeAction(name) {
|
|
57
|
+
this.actions.delete(name);
|
|
58
|
+
}
|
|
59
|
+
|
|
44
60
|
}
|
|
45
|
-
|
|
46
|
-
|
|
61
|
+
|
|
62
|
+
exports.ACLResource = ACLResource;
|
package/lib/acl-role.js
CHANGED
|
@@ -1,90 +1,162 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
3
6
|
exports.ACLRole = void 0;
|
|
4
|
-
|
|
7
|
+
|
|
8
|
+
var _aclResource = require("./acl-resource");
|
|
9
|
+
|
|
10
|
+
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e2) { throw _e2; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e3) { didErr = true; err = _e3; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
|
|
11
|
+
|
|
12
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
13
|
+
|
|
14
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
15
|
+
|
|
16
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
17
|
+
|
|
18
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
19
|
+
|
|
20
|
+
function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
|
|
21
|
+
|
|
22
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
23
|
+
|
|
5
24
|
class ACLRole {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
25
|
+
constructor(acl, name) {
|
|
26
|
+
this.acl = void 0;
|
|
27
|
+
this.name = void 0;
|
|
28
|
+
this.strategy = void 0;
|
|
29
|
+
this.resources = new Map();
|
|
30
|
+
this.acl = acl;
|
|
31
|
+
this.name = name;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
getResource(name) {
|
|
35
|
+
return this.resources.get(name);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
setResource(name, resource) {
|
|
39
|
+
this.resources.set(name, resource);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
setStrategy(value) {
|
|
43
|
+
this.strategy = value;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
grantResource(resourceName, options) {
|
|
47
|
+
const resource = new _aclResource.ACLResource({
|
|
48
|
+
role: this,
|
|
49
|
+
name: resourceName
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
for (var _i = 0, _Object$entries = Object.entries(options); _i < _Object$entries.length; _i++) {
|
|
53
|
+
const _Object$entries$_i = _slicedToArray(_Object$entries[_i], 2),
|
|
54
|
+
actionName = _Object$entries$_i[0],
|
|
55
|
+
actionParams = _Object$entries$_i[1];
|
|
56
|
+
|
|
57
|
+
resource.setAction(actionName, actionParams);
|
|
10
58
|
}
|
|
11
|
-
|
|
12
|
-
|
|
59
|
+
|
|
60
|
+
this.resources.set(resourceName, resource);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
getResourceActionsParams(resourceName) {
|
|
64
|
+
const resource = this.getResource(resourceName);
|
|
65
|
+
return resource.getActions();
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
revokeResource(resourceName) {
|
|
69
|
+
for (var _i2 = 0, _arr2 = [...this.resources.keys()]; _i2 < _arr2.length; _i2++) {
|
|
70
|
+
const key = _arr2[_i2];
|
|
71
|
+
|
|
72
|
+
if (key === resourceName || key.includes(`${resourceName}.`)) {
|
|
73
|
+
this.resources.delete(key);
|
|
74
|
+
}
|
|
13
75
|
}
|
|
14
|
-
|
|
15
|
-
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
grantAction(path, options) {
|
|
79
|
+
let _this$getResourceActi = this.getResourceActionFromPath(path),
|
|
80
|
+
resource = _this$getResourceActi.resource,
|
|
81
|
+
resourceName = _this$getResourceActi.resourceName,
|
|
82
|
+
actionName = _this$getResourceActi.actionName;
|
|
83
|
+
|
|
84
|
+
if (!resource) {
|
|
85
|
+
resource = new _aclResource.ACLResource({
|
|
86
|
+
role: this,
|
|
87
|
+
name: resourceName
|
|
88
|
+
});
|
|
89
|
+
this.resources.set(resourceName, resource);
|
|
16
90
|
}
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
91
|
+
|
|
92
|
+
resource.setAction(actionName, options);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
getActionParams(path) {
|
|
96
|
+
const _this$getResourceActi2 = this.getResourceActionFromPath(path),
|
|
97
|
+
action = _this$getResourceActi2.action;
|
|
98
|
+
|
|
99
|
+
return action;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
revokeAction(path) {
|
|
103
|
+
const _this$getResourceActi3 = this.getResourceActionFromPath(path),
|
|
104
|
+
resource = _this$getResourceActi3.resource,
|
|
105
|
+
actionName = _this$getResourceActi3.actionName;
|
|
106
|
+
|
|
107
|
+
resource.removeAction(actionName);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
toJSON() {
|
|
111
|
+
const actions = {};
|
|
112
|
+
|
|
113
|
+
var _iterator = _createForOfIteratorHelper(this.resources.keys()),
|
|
114
|
+
_step;
|
|
115
|
+
|
|
116
|
+
try {
|
|
117
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
118
|
+
const resourceName = _step.value;
|
|
119
|
+
const resourceActions = this.getResourceActionsParams(resourceName);
|
|
120
|
+
|
|
121
|
+
for (var _i3 = 0, _Object$keys = Object.keys(resourceActions); _i3 < _Object$keys.length; _i3++) {
|
|
122
|
+
const actionName = _Object$keys[_i3];
|
|
123
|
+
actions[`${resourceName}:${actionName}`] = resourceActions[actionName];
|
|
49
124
|
}
|
|
50
|
-
|
|
125
|
+
}
|
|
126
|
+
} catch (err) {
|
|
127
|
+
_iterator.e(err);
|
|
128
|
+
} finally {
|
|
129
|
+
_iterator.f();
|
|
51
130
|
}
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
actions,
|
|
72
|
-
};
|
|
73
|
-
}
|
|
74
|
-
getResourceActionFromPath(path) {
|
|
75
|
-
const [resourceName, actionName] = path.split(':');
|
|
76
|
-
const resource = this.resources.get(resourceName);
|
|
77
|
-
let action = null;
|
|
78
|
-
if (resource) {
|
|
79
|
-
action = resource.getAction(actionName);
|
|
80
|
-
}
|
|
81
|
-
return {
|
|
82
|
-
resourceName,
|
|
83
|
-
actionName,
|
|
84
|
-
resource,
|
|
85
|
-
action,
|
|
86
|
-
};
|
|
131
|
+
|
|
132
|
+
return {
|
|
133
|
+
role: this.name,
|
|
134
|
+
strategy: this.strategy,
|
|
135
|
+
actions
|
|
136
|
+
};
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
getResourceActionFromPath(path) {
|
|
140
|
+
const _path$split = path.split(':'),
|
|
141
|
+
_path$split2 = _slicedToArray(_path$split, 2),
|
|
142
|
+
resourceName = _path$split2[0],
|
|
143
|
+
actionName = _path$split2[1];
|
|
144
|
+
|
|
145
|
+
const resource = this.resources.get(resourceName);
|
|
146
|
+
let action = null;
|
|
147
|
+
|
|
148
|
+
if (resource) {
|
|
149
|
+
action = resource.getAction(actionName);
|
|
87
150
|
}
|
|
151
|
+
|
|
152
|
+
return {
|
|
153
|
+
resourceName,
|
|
154
|
+
actionName,
|
|
155
|
+
resource,
|
|
156
|
+
action
|
|
157
|
+
};
|
|
158
|
+
}
|
|
159
|
+
|
|
88
160
|
}
|
|
89
|
-
|
|
90
|
-
|
|
161
|
+
|
|
162
|
+
exports.ACLRole = ACLRole;
|