@nocobase/plugin-acl 2.1.0-alpha.2 → 2.1.0-alpha.20
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/LICENSE +201 -661
- package/README.md +79 -10
- package/client-v2.d.ts +2 -0
- package/client-v2.js +1 -0
- package/dist/client/949.7ad4ad3b554e5452.js +10 -0
- package/dist/client/971.50ecf7b6ac572080.js +10 -0
- package/dist/client/index.js +1 -1
- package/dist/client-v2/139.929bc11d582ef7d4.js +10 -0
- package/dist/client-v2/193.3245b23f17b4c9f8.js +10 -0
- package/dist/client-v2/366.069b6cf12cfb9a67.js +10 -0
- package/dist/client-v2/627.ce101823deb86dd6.js +10 -0
- package/dist/client-v2/index.d.ts +9 -0
- package/dist/client-v2/index.js +10 -0
- package/dist/client-v2/plugin.d.ts +5 -0
- package/dist/client-v2/routes/AppInfoDemoRoute.d.ts +10 -0
- package/dist/client-v2/routes/DemoHomepageRoute.d.ts +10 -0
- package/dist/client-v2/routes/FlowSettingsComponentLoaderDemoRoute.d.ts +2 -0
- package/dist/client-v2/settings/DemoFlowSettingsLazyField.d.ts +10 -0
- package/dist/externalVersion.js +11 -9
- package/dist/server/index.d.ts +1 -0
- package/dist/server/index.js +2 -0
- package/dist/server/middlewares/check-association-operate.js +14 -5
- package/dist/server/middlewares/check-change-with-association.d.ts +21 -0
- package/dist/server/middlewares/check-change-with-association.js +327 -246
- package/dist/server/middlewares/check-query-permission.d.ts +10 -0
- package/dist/server/middlewares/check-query-permission.js +64 -0
- package/dist/server/middlewares/with-acl-meta.js +7 -2
- package/dist/server/migrations/20251119225252-update-member-default-permission.js +1 -1
- package/dist/server/query/apply-query-permission.d.ts +27 -0
- package/dist/server/query/apply-query-permission.js +242 -0
- package/dist/server/server.d.ts +6 -1
- package/dist/server/server.js +8 -1
- package/dist/swagger/index.d.ts +962 -143
- package/dist/swagger/index.js +854 -183
- package/package.json +5 -3
- package/dist/client/0655d5ded9f45bb1.js +0 -10
- package/dist/client/50204a14518b3a0d.js +0 -10
package/dist/server/index.d.ts
CHANGED
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
*/
|
|
9
9
|
export * from './middlewares/setCurrentRole';
|
|
10
10
|
export * from './middlewares/with-acl-meta';
|
|
11
|
+
export * from './query/apply-query-permission';
|
|
11
12
|
export { RoleResourceActionModel } from './model/RoleResourceActionModel';
|
|
12
13
|
export { RoleResourceModel } from './model/RoleResourceModel';
|
|
13
14
|
export * from './constants';
|
package/dist/server/index.js
CHANGED
|
@@ -44,6 +44,7 @@ __export(server_exports, {
|
|
|
44
44
|
module.exports = __toCommonJS(server_exports);
|
|
45
45
|
__reExport(server_exports, require("./middlewares/setCurrentRole"), module.exports);
|
|
46
46
|
__reExport(server_exports, require("./middlewares/with-acl-meta"), module.exports);
|
|
47
|
+
__reExport(server_exports, require("./query/apply-query-permission"), module.exports);
|
|
47
48
|
var import_RoleResourceActionModel = require("./model/RoleResourceActionModel");
|
|
48
49
|
var import_RoleResourceModel = require("./model/RoleResourceModel");
|
|
49
50
|
__reExport(server_exports, require("./constants"), module.exports);
|
|
@@ -55,6 +56,7 @@ var import_server = __toESM(require("./server"));
|
|
|
55
56
|
RoleResourceModel,
|
|
56
57
|
...require("./middlewares/setCurrentRole"),
|
|
57
58
|
...require("./middlewares/with-acl-meta"),
|
|
59
|
+
...require("./query/apply-query-permission"),
|
|
58
60
|
...require("./constants"),
|
|
59
61
|
...require("./enum")
|
|
60
62
|
});
|
|
@@ -31,7 +31,7 @@ __export(check_association_operate_exports, {
|
|
|
31
31
|
module.exports = __toCommonJS(check_association_operate_exports);
|
|
32
32
|
var import_acl = require("@nocobase/acl");
|
|
33
33
|
async function checkAssociationOperate(ctx, next) {
|
|
34
|
-
var _a;
|
|
34
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
|
|
35
35
|
const { actionName, resourceName, sourceId } = ctx.action;
|
|
36
36
|
if (!(resourceName.includes(".") && ["add", "set", "remove", "toggle"].includes(actionName))) {
|
|
37
37
|
return next();
|
|
@@ -59,12 +59,21 @@ async function checkAssociationOperate(ctx, next) {
|
|
|
59
59
|
}
|
|
60
60
|
if (params.filter) {
|
|
61
61
|
try {
|
|
62
|
-
const
|
|
63
|
-
const
|
|
64
|
-
|
|
62
|
+
const timezone = ((_c = (_b = ctx.request) == null ? void 0 : _b.get) == null ? void 0 : _c.call(_b, "x-timezone")) ?? ((_e = (_d = ctx.request) == null ? void 0 : _d.header) == null ? void 0 : _e["x-timezone"]) ?? ((_g = (_f = ctx.req) == null ? void 0 : _f.headers) == null ? void 0 : _g["x-timezone"]);
|
|
63
|
+
const collection = (_i = (_h = ctx.database) == null ? void 0 : _h.getCollection) == null ? void 0 : _i.call(_h, resource);
|
|
64
|
+
(0, import_acl.checkFilterParams)(collection, params.filter);
|
|
65
|
+
const parsedFilter = await (0, import_acl.parseJsonTemplate)(params.filter, {
|
|
66
|
+
state: ctx.state,
|
|
67
|
+
timezone,
|
|
68
|
+
userProvider: (0, import_acl.createUserProvider)({
|
|
69
|
+
db: ctx.db,
|
|
70
|
+
currentUser: (_j = ctx.state) == null ? void 0 : _j.currentUser
|
|
71
|
+
})
|
|
72
|
+
});
|
|
73
|
+
const repo = ctx.database.getRepository(resource);
|
|
65
74
|
const record = await repo.findOne({
|
|
66
75
|
filterByTk: sourceId,
|
|
67
|
-
filter:
|
|
76
|
+
filter: parsedFilter ?? params.filter
|
|
68
77
|
});
|
|
69
78
|
if (!record) {
|
|
70
79
|
ctx.throw(403, "No permissions");
|
|
@@ -6,5 +6,26 @@
|
|
|
6
6
|
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
7
|
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
8
|
*/
|
|
9
|
+
import { ACL, UserProvider } from '@nocobase/acl';
|
|
9
10
|
import { Context, Next } from '@nocobase/actions';
|
|
11
|
+
import { Collection } from '@nocobase/database';
|
|
12
|
+
export type SanitizeAssociationValuesOptions = {
|
|
13
|
+
acl?: ACL;
|
|
14
|
+
resourceName: string;
|
|
15
|
+
actionName: string;
|
|
16
|
+
values: any;
|
|
17
|
+
updateAssociationValues?: string[];
|
|
18
|
+
protectedKeys?: string[];
|
|
19
|
+
aclParams?: any;
|
|
20
|
+
roles?: string[];
|
|
21
|
+
currentRole?: string;
|
|
22
|
+
currentUser?: any;
|
|
23
|
+
collection?: Collection;
|
|
24
|
+
db?: any;
|
|
25
|
+
database?: any;
|
|
26
|
+
state?: Record<string, any>;
|
|
27
|
+
timezone?: string;
|
|
28
|
+
userProvider?: UserProvider;
|
|
29
|
+
};
|
|
30
|
+
export declare function sanitizeAssociationValues(options: SanitizeAssociationValuesOptions): Promise<any>;
|
|
10
31
|
export declare const checkChangesWithAssociation: (ctx: Context, next: Next) => Promise<any>;
|