@nocobase/plugin-acl 0.9.0-alpha.2 → 0.9.1-alpha.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/README.md +11 -0
- package/README.zh-CN.md +11 -0
- package/lib/collections/roles-users.js +2 -0
- package/lib/collections/roles.js +2 -0
- package/lib/collections/rolesResources.js +2 -0
- package/lib/collections/rolesResourcesActions.js +2 -0
- package/lib/collections/rolesResourcesScopes.js +2 -0
- package/lib/server.js +63 -13
- package/package.json +6 -6
package/README.md
ADDED
package/README.zh-CN.md
ADDED
package/lib/collections/roles.js
CHANGED
package/lib/server.js
CHANGED
|
@@ -901,17 +901,17 @@ class PluginACL extends _server().Plugin {
|
|
|
901
901
|
return;
|
|
902
902
|
}
|
|
903
903
|
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
if (!collection) {
|
|
904
|
+
if (ctx.status !== 200) {
|
|
907
905
|
return;
|
|
908
906
|
}
|
|
909
907
|
|
|
910
|
-
if (
|
|
908
|
+
if (!['list', 'get'].includes(actionName)) {
|
|
911
909
|
return;
|
|
912
910
|
}
|
|
913
911
|
|
|
914
|
-
|
|
912
|
+
const collection = ctx.db.getCollection(resourceName);
|
|
913
|
+
|
|
914
|
+
if (!collection) {
|
|
915
915
|
return;
|
|
916
916
|
}
|
|
917
917
|
|
|
@@ -978,7 +978,7 @@ class PluginACL extends _server().Plugin {
|
|
|
978
978
|
throw e;
|
|
979
979
|
}
|
|
980
980
|
|
|
981
|
-
actionsParams.push([action, ((_actionCtx$permission = actionCtx.permission) === null || _actionCtx$permission === void 0 ? void 0 : _actionCtx$permission.can) === null && !actionCtx.permission.skip ? null : ((_actionCtx$permission2 = actionCtx.permission) === null || _actionCtx$permission2 === void 0 ? void 0 : _actionCtx$permission2.parsedParams) || {}]);
|
|
981
|
+
actionsParams.push([action, ((_actionCtx$permission = actionCtx.permission) === null || _actionCtx$permission === void 0 ? void 0 : _actionCtx$permission.can) === null && !actionCtx.permission.skip ? null : ((_actionCtx$permission2 = actionCtx.permission) === null || _actionCtx$permission2 === void 0 ? void 0 : _actionCtx$permission2.parsedParams) || {}, actionCtx]);
|
|
982
982
|
}
|
|
983
983
|
|
|
984
984
|
const ids = listData.map(item => item[primaryKeyField]);
|
|
@@ -986,9 +986,10 @@ class PluginACL extends _server().Plugin {
|
|
|
986
986
|
const allAllowed = [];
|
|
987
987
|
|
|
988
988
|
for (var _i3 = 0, _actionsParams = actionsParams; _i3 < _actionsParams.length; _i3++) {
|
|
989
|
-
const _actionsParams$_i = _slicedToArray(_actionsParams[_i3],
|
|
989
|
+
const _actionsParams$_i = _slicedToArray(_actionsParams[_i3], 3),
|
|
990
990
|
action = _actionsParams$_i[0],
|
|
991
|
-
params = _actionsParams$_i[1]
|
|
991
|
+
params = _actionsParams$_i[1],
|
|
992
|
+
actionCtx = _actionsParams$_i[2];
|
|
992
993
|
|
|
993
994
|
if (!params) {
|
|
994
995
|
continue;
|
|
@@ -999,13 +1000,56 @@ class PluginACL extends _server().Plugin {
|
|
|
999
1000
|
continue;
|
|
1000
1001
|
}
|
|
1001
1002
|
|
|
1002
|
-
const queryParams = collection.repository.buildQueryOptions(params)
|
|
1003
|
+
const queryParams = collection.repository.buildQueryOptions(_objectSpread(_objectSpread({}, params), {}, {
|
|
1004
|
+
context: actionCtx
|
|
1005
|
+
}));
|
|
1003
1006
|
const actionSql = ctx.db.sequelize.queryInterface.queryGenerator.selectQuery(Model.getTableName(), {
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1007
|
+
where: (() => {
|
|
1008
|
+
const filterObj = queryParams.where;
|
|
1009
|
+
|
|
1010
|
+
if (!_this4.db.options.underscored) {
|
|
1011
|
+
return filterObj;
|
|
1012
|
+
}
|
|
1008
1013
|
|
|
1014
|
+
const iterate = (rootObj, path = []) => {
|
|
1015
|
+
const obj = path.length == 0 ? rootObj : _lodash().default.get(rootObj, path);
|
|
1016
|
+
|
|
1017
|
+
if (Array.isArray(obj)) {
|
|
1018
|
+
for (let i = 0; i < obj.length; i++) {
|
|
1019
|
+
if (obj[i] === null) {
|
|
1020
|
+
continue;
|
|
1021
|
+
}
|
|
1022
|
+
|
|
1023
|
+
if (typeof obj[i] === 'object') {
|
|
1024
|
+
iterate(rootObj, [...path, i]);
|
|
1025
|
+
}
|
|
1026
|
+
}
|
|
1027
|
+
|
|
1028
|
+
return;
|
|
1029
|
+
}
|
|
1030
|
+
|
|
1031
|
+
Reflect.ownKeys(obj).forEach(key => {
|
|
1032
|
+
if (Array.isArray(obj) && key == 'length') {
|
|
1033
|
+
return;
|
|
1034
|
+
}
|
|
1035
|
+
|
|
1036
|
+
if (typeof obj[key] === 'object' && obj[key] !== null || typeof obj[key] === 'symbol') {
|
|
1037
|
+
iterate(rootObj, [...path, key]);
|
|
1038
|
+
}
|
|
1039
|
+
|
|
1040
|
+
if (typeof key === 'string' && key !== (0, _database().snakeCase)(key)) {
|
|
1041
|
+
_lodash().default.set(rootObj, [...path, (0, _database().snakeCase)(key)], _lodash().default.cloneDeep(obj[key]));
|
|
1042
|
+
|
|
1043
|
+
_lodash().default.unset(rootObj, [...path, key]);
|
|
1044
|
+
}
|
|
1045
|
+
});
|
|
1046
|
+
};
|
|
1047
|
+
|
|
1048
|
+
iterate(filterObj);
|
|
1049
|
+
return filterObj;
|
|
1050
|
+
})(),
|
|
1051
|
+
attributes: [primaryKeyField],
|
|
1052
|
+
includeIgnoreAttributes: false
|
|
1009
1053
|
}, Model);
|
|
1010
1054
|
const whereCase = actionSql.match(/WHERE (.*?);/)[1];
|
|
1011
1055
|
conditions.push({
|
|
@@ -1088,6 +1132,12 @@ class PluginACL extends _server().Plugin {
|
|
|
1088
1132
|
|
|
1089
1133
|
return _asyncToGenerator(function* () {
|
|
1090
1134
|
yield _this6.importCollections((0, _path().resolve)(__dirname, 'collections'));
|
|
1135
|
+
|
|
1136
|
+
_this6.db.extendCollection({
|
|
1137
|
+
name: 'rolesUischemas',
|
|
1138
|
+
namespace: 'acl',
|
|
1139
|
+
duplicator: 'required'
|
|
1140
|
+
});
|
|
1091
1141
|
})();
|
|
1092
1142
|
}
|
|
1093
1143
|
|
package/package.json
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nocobase/plugin-acl",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.1-alpha.2",
|
|
4
4
|
"description": "",
|
|
5
5
|
"license": "AGPL-3.0",
|
|
6
6
|
"main": "./lib/index.js",
|
|
7
7
|
"types": "./lib/index.d.ts",
|
|
8
8
|
"dependencies": {
|
|
9
|
-
"@nocobase/acl": "0.9.
|
|
10
|
-
"@nocobase/database": "0.9.
|
|
11
|
-
"@nocobase/plugin-users": "0.9.
|
|
12
|
-
"@nocobase/server": "0.9.
|
|
9
|
+
"@nocobase/acl": "0.9.1-alpha.2",
|
|
10
|
+
"@nocobase/database": "0.9.1-alpha.2",
|
|
11
|
+
"@nocobase/plugin-users": "0.9.1-alpha.2",
|
|
12
|
+
"@nocobase/server": "0.9.1-alpha.2"
|
|
13
13
|
},
|
|
14
14
|
"repository": {
|
|
15
15
|
"type": "git",
|
|
16
16
|
"url": "git+https://github.com/nocobase/nocobase.git",
|
|
17
17
|
"directory": "packages/plugins/acl"
|
|
18
18
|
},
|
|
19
|
-
"gitHead": "
|
|
19
|
+
"gitHead": "d588a68eca4feed4642a4cb317301011266fe5c9"
|
|
20
20
|
}
|