@nocobase/plugin-acl 0.21.0-alpha.9 → 1.0.0-alpha.10
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/dist/client/NewRole.d.ts +8 -0
- package/dist/client/RolesManagement.d.ts +8 -0
- package/dist/client/RolesManagerProvider.d.ts +8 -0
- package/dist/client/RolesMenu.d.ts +8 -0
- package/dist/client/hooks/load-more-observer.d.ts +8 -0
- package/dist/client/index.d.ts +8 -0
- package/dist/client/index.js +9 -0
- package/dist/client/locale.d.ts +8 -0
- package/dist/client/permissions/ActionPermissions.d.ts +8 -0
- package/dist/client/permissions/AvailableActions.d.ts +8 -0
- package/dist/client/permissions/GeneralPermissions.d.ts +8 -0
- package/dist/client/permissions/MenuItemsProvider.d.ts +8 -0
- package/dist/client/permissions/MenuPermissions.d.ts +8 -0
- package/dist/client/permissions/Permissions.d.ts +8 -0
- package/dist/client/permissions/PluginPermissions.d.ts +8 -0
- package/dist/client/permissions/RolesResourcesActions.d.ts +8 -0
- package/dist/client/permissions/ScopeSelect.d.ts +8 -0
- package/dist/client/permissions/StrategyActions.d.ts +8 -0
- package/dist/client/permissions/style.d.ts +8 -0
- package/dist/client/roles-manager.d.ts +8 -0
- package/dist/client/schemas/roles.d.ts +8 -0
- package/dist/client/schemas/scopes.d.ts +8 -0
- package/dist/externalVersion.js +17 -8
- package/dist/index.d.ts +8 -0
- package/dist/index.js +9 -0
- package/dist/server/actions/available-actions.d.ts +8 -0
- package/dist/server/actions/available-actions.js +9 -0
- package/dist/server/actions/role-check.d.ts +8 -0
- package/dist/server/actions/role-check.js +9 -0
- package/dist/server/actions/role-collections.d.ts +8 -0
- package/dist/server/actions/role-collections.js +9 -0
- package/dist/server/actions/user-setDefaultRole.d.ts +8 -0
- package/dist/server/actions/user-setDefaultRole.js +9 -0
- package/dist/server/collections/roles-users.d.ts +8 -0
- package/dist/server/collections/roles-users.js +9 -0
- package/dist/server/collections/roles.d.ts +8 -0
- package/dist/server/collections/roles.js +9 -0
- package/dist/server/collections/rolesResources.d.ts +8 -0
- package/dist/server/collections/rolesResources.js +9 -0
- package/dist/server/collections/rolesResourcesActions.d.ts +8 -0
- package/dist/server/collections/rolesResourcesActions.js +9 -0
- package/dist/server/collections/rolesResourcesScopes.d.ts +8 -0
- package/dist/server/collections/rolesResourcesScopes.js +9 -0
- package/dist/server/collections/users.d.ts +8 -0
- package/dist/server/collections/users.js +9 -0
- package/dist/server/index.d.ts +8 -0
- package/dist/server/index.js +9 -0
- package/dist/server/middlewares/setCurrentRole.d.ts +8 -0
- package/dist/server/middlewares/setCurrentRole.js +9 -0
- package/dist/server/middlewares/with-acl-meta.d.ts +8 -0
- package/dist/server/middlewares/with-acl-meta.js +13 -3
- package/dist/server/migrations/20221214072638-set-role-snippets.d.ts +8 -0
- package/dist/server/migrations/20221214072638-set-role-snippets.js +10 -0
- package/dist/server/model/RoleModel.d.ts +8 -0
- package/dist/server/model/RoleModel.js +9 -0
- package/dist/server/model/RoleResourceActionModel.d.ts +8 -3
- package/dist/server/model/RoleResourceActionModel.js +10 -42
- package/dist/server/model/RoleResourceModel.d.ts +8 -4
- package/dist/server/model/RoleResourceModel.js +13 -17
- package/dist/server/server.d.ts +11 -21
- package/dist/server/server.js +11 -66
- package/dist/swagger/index.d.ts +8 -0
- package/dist/swagger/index.js +9 -0
- package/package.json +10 -10
|
@@ -1,3 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file is part of the NocoBase (R) project.
|
|
3
|
+
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
+
* Authors: NocoBase Team.
|
|
5
|
+
*
|
|
6
|
+
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
+
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
+
*/
|
|
9
|
+
|
|
1
10
|
var __defProp = Object.defineProperty;
|
|
2
11
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
12
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
package/dist/server/index.d.ts
CHANGED
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file is part of the NocoBase (R) project.
|
|
3
|
+
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
+
* Authors: NocoBase Team.
|
|
5
|
+
*
|
|
6
|
+
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
+
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
+
*/
|
|
1
9
|
export * from './middlewares/setCurrentRole';
|
|
2
10
|
export * from './middlewares/with-acl-meta';
|
|
3
11
|
export { RoleResourceActionModel } from './model/RoleResourceActionModel';
|
package/dist/server/index.js
CHANGED
|
@@ -1,3 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file is part of the NocoBase (R) project.
|
|
3
|
+
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
+
* Authors: NocoBase Team.
|
|
5
|
+
*
|
|
6
|
+
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
+
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
+
*/
|
|
9
|
+
|
|
1
10
|
var __create = Object.create;
|
|
2
11
|
var __defProp = Object.defineProperty;
|
|
3
12
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
@@ -1,2 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file is part of the NocoBase (R) project.
|
|
3
|
+
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
+
* Authors: NocoBase Team.
|
|
5
|
+
*
|
|
6
|
+
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
+
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
+
*/
|
|
1
9
|
import { Context } from '@nocobase/actions';
|
|
2
10
|
export declare function setCurrentRole(ctx: Context, next: any): Promise<any>;
|
|
@@ -1,3 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file is part of the NocoBase (R) project.
|
|
3
|
+
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
+
* Authors: NocoBase Team.
|
|
5
|
+
*
|
|
6
|
+
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
+
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
+
*/
|
|
9
|
+
|
|
1
10
|
var __defProp = Object.defineProperty;
|
|
2
11
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
12
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
@@ -1,2 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file is part of the NocoBase (R) project.
|
|
3
|
+
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
+
* Authors: NocoBase Team.
|
|
5
|
+
*
|
|
6
|
+
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
+
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
+
*/
|
|
1
9
|
declare function createWithACLMetaMiddleware(): (ctx: any, next: any) => Promise<void>;
|
|
2
10
|
export { createWithACLMetaMiddleware };
|
|
@@ -1,3 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file is part of the NocoBase (R) project.
|
|
3
|
+
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
+
* Authors: NocoBase Team.
|
|
5
|
+
*
|
|
6
|
+
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
+
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
+
*/
|
|
9
|
+
|
|
1
10
|
var __create = Object.create;
|
|
2
11
|
var __defProp = Object.defineProperty;
|
|
3
12
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
@@ -31,8 +40,9 @@ __export(with_acl_meta_exports, {
|
|
|
31
40
|
});
|
|
32
41
|
module.exports = __toCommonJS(with_acl_meta_exports);
|
|
33
42
|
var import_lodash = __toESM(require("lodash"));
|
|
34
|
-
var import_acl = require("@nocobase/acl");
|
|
35
43
|
var import_database = require("@nocobase/database");
|
|
44
|
+
class NoPermissionError extends Error {
|
|
45
|
+
}
|
|
36
46
|
function createWithACLMetaMiddleware() {
|
|
37
47
|
return async (ctx, next) => {
|
|
38
48
|
var _a, _b, _c, _d;
|
|
@@ -109,13 +119,13 @@ function createWithACLMetaMiddleware() {
|
|
|
109
119
|
},
|
|
110
120
|
permission: {},
|
|
111
121
|
throw(...args) {
|
|
112
|
-
throw new
|
|
122
|
+
throw new NoPermissionError(...args);
|
|
113
123
|
}
|
|
114
124
|
};
|
|
115
125
|
try {
|
|
116
126
|
await acl.getActionParams(actionCtx);
|
|
117
127
|
} catch (e) {
|
|
118
|
-
if (e instanceof
|
|
128
|
+
if (e instanceof NoPermissionError) {
|
|
119
129
|
continue;
|
|
120
130
|
}
|
|
121
131
|
throw e;
|
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file is part of the NocoBase (R) project.
|
|
3
|
+
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
+
* Authors: NocoBase Team.
|
|
5
|
+
*
|
|
6
|
+
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
+
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
+
*/
|
|
1
9
|
import { Migration } from '@nocobase/server';
|
|
2
10
|
export default class extends Migration {
|
|
3
11
|
appVersion: string;
|
|
@@ -1,3 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file is part of the NocoBase (R) project.
|
|
3
|
+
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
+
* Authors: NocoBase Team.
|
|
5
|
+
*
|
|
6
|
+
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
+
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
+
*/
|
|
9
|
+
|
|
1
10
|
var __defProp = Object.defineProperty;
|
|
2
11
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
12
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
@@ -21,6 +30,7 @@ __export(set_role_snippets_exports, {
|
|
|
21
30
|
});
|
|
22
31
|
module.exports = __toCommonJS(set_role_snippets_exports);
|
|
23
32
|
var import_server = require("@nocobase/server");
|
|
33
|
+
/* istanbul ignore file -- @preserve */
|
|
24
34
|
class set_role_snippets_default extends import_server.Migration {
|
|
25
35
|
appVersion = "<0.9.0-alpha.1";
|
|
26
36
|
async up() {
|
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file is part of the NocoBase (R) project.
|
|
3
|
+
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
+
* Authors: NocoBase Team.
|
|
5
|
+
*
|
|
6
|
+
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
+
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
+
*/
|
|
1
9
|
import { Model } from '@nocobase/database';
|
|
2
10
|
import { ACL } from '@nocobase/acl';
|
|
3
11
|
export declare class RoleModel extends Model {
|
|
@@ -1,3 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file is part of the NocoBase (R) project.
|
|
3
|
+
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
+
* Authors: NocoBase Team.
|
|
5
|
+
*
|
|
6
|
+
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
+
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
+
*/
|
|
9
|
+
|
|
1
10
|
var __defProp = Object.defineProperty;
|
|
2
11
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
12
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
@@ -1,12 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file is part of the NocoBase (R) project.
|
|
3
|
+
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
+
* Authors: NocoBase Team.
|
|
5
|
+
*
|
|
6
|
+
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
+
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
+
*/
|
|
1
9
|
import { ACL, ACLRole } from '@nocobase/acl';
|
|
2
10
|
import { Model } from '@nocobase/database';
|
|
3
|
-
import { AssociationFieldsActions, GrantHelper } from '../server';
|
|
4
11
|
export declare class RoleResourceActionModel extends Model {
|
|
5
12
|
writeToACL(options: {
|
|
6
13
|
acl: ACL;
|
|
7
14
|
role: ACLRole;
|
|
8
15
|
resourceName: string;
|
|
9
|
-
associationFieldsActions: AssociationFieldsActions;
|
|
10
|
-
grantHelper: GrantHelper;
|
|
11
16
|
}): Promise<void>;
|
|
12
17
|
}
|
|
@@ -1,3 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file is part of the NocoBase (R) project.
|
|
3
|
+
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
+
* Authors: NocoBase Team.
|
|
5
|
+
*
|
|
6
|
+
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
+
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
+
*/
|
|
9
|
+
|
|
1
10
|
var __defProp = Object.defineProperty;
|
|
2
11
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
12
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
@@ -23,9 +32,7 @@ module.exports = __toCommonJS(RoleResourceActionModel_exports);
|
|
|
23
32
|
var import_database = require("@nocobase/database");
|
|
24
33
|
class RoleResourceActionModel extends import_database.Model {
|
|
25
34
|
async writeToACL(options) {
|
|
26
|
-
|
|
27
|
-
const db = this.constructor.database;
|
|
28
|
-
const { resourceName, role, acl, associationFieldsActions, grantHelper } = options;
|
|
35
|
+
const { resourceName, role } = options;
|
|
29
36
|
const actionName = this.get("name");
|
|
30
37
|
const fields = this.get("fields");
|
|
31
38
|
const actionPath = `${resourceName}:${actionName}`;
|
|
@@ -38,45 +45,6 @@ class RoleResourceActionModel extends import_database.Model {
|
|
|
38
45
|
actionParams["filter"] = scope.get("scope");
|
|
39
46
|
}
|
|
40
47
|
role.grantAction(actionPath, actionParams);
|
|
41
|
-
const collection = db.getCollection(resourceName);
|
|
42
|
-
if (!collection) {
|
|
43
|
-
return;
|
|
44
|
-
}
|
|
45
|
-
const availableAction = acl.resolveActionAlias(actionName);
|
|
46
|
-
for (const field of fields) {
|
|
47
|
-
const collectionField = collection.getField(field);
|
|
48
|
-
if (!collectionField) {
|
|
49
|
-
console.log(`field ${field} does not exist at ${collection.name}`);
|
|
50
|
-
continue;
|
|
51
|
-
}
|
|
52
|
-
const fieldType = collectionField.get("type");
|
|
53
|
-
const fieldActions = (_a = associationFieldsActions == null ? void 0 : associationFieldsActions[fieldType]) == null ? void 0 : _a[availableAction];
|
|
54
|
-
const fieldTarget = collectionField.get("target");
|
|
55
|
-
if (fieldActions) {
|
|
56
|
-
const associationActions = fieldActions.associationActions || [];
|
|
57
|
-
associationActions.forEach((associationAction) => {
|
|
58
|
-
const actionName2 = `${resourceName}.${collectionField.get("name")}:${associationAction}`;
|
|
59
|
-
role.grantAction(actionName2);
|
|
60
|
-
});
|
|
61
|
-
const targetActions = fieldActions.targetActions || [];
|
|
62
|
-
targetActions.forEach((targetAction) => {
|
|
63
|
-
const targetActionPath = `${fieldTarget}:${targetAction}`;
|
|
64
|
-
const existsAction = role.getActionParams(targetActionPath);
|
|
65
|
-
if (existsAction) {
|
|
66
|
-
return;
|
|
67
|
-
}
|
|
68
|
-
grantHelper.resourceTargetActionMap.set(`${role.name}.${resourceName}`, [
|
|
69
|
-
...grantHelper.resourceTargetActionMap.get(resourceName) || [],
|
|
70
|
-
targetActionPath
|
|
71
|
-
]);
|
|
72
|
-
grantHelper.targetActionResourceMap.set(targetActionPath, [
|
|
73
|
-
...grantHelper.targetActionResourceMap.get(targetActionPath) || [],
|
|
74
|
-
`${role.name}.${resourceName}`
|
|
75
|
-
]);
|
|
76
|
-
role.grantAction(targetActionPath);
|
|
77
|
-
});
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
48
|
}
|
|
81
49
|
}
|
|
82
50
|
// Annotate the CommonJS export names for ESM import in node:
|
|
@@ -1,16 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file is part of the NocoBase (R) project.
|
|
3
|
+
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
+
* Authors: NocoBase Team.
|
|
5
|
+
*
|
|
6
|
+
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
+
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
+
*/
|
|
1
9
|
import { ACL, ACLRole } from '@nocobase/acl';
|
|
2
10
|
import { Model } from '@nocobase/database';
|
|
3
|
-
import { AssociationFieldsActions, GrantHelper } from '../server';
|
|
4
11
|
export declare class RoleResourceModel extends Model {
|
|
5
12
|
revoke(options: {
|
|
6
13
|
role: ACLRole;
|
|
7
14
|
resourceName: string;
|
|
8
|
-
grantHelper: GrantHelper;
|
|
9
15
|
}): Promise<void>;
|
|
10
16
|
writeToACL(options: {
|
|
11
17
|
acl: ACL;
|
|
12
|
-
associationFieldsActions: AssociationFieldsActions;
|
|
13
|
-
grantHelper: GrantHelper;
|
|
14
18
|
transaction: any;
|
|
15
19
|
}): Promise<void>;
|
|
16
20
|
}
|
|
@@ -1,3 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file is part of the NocoBase (R) project.
|
|
3
|
+
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
+
* Authors: NocoBase Team.
|
|
5
|
+
*
|
|
6
|
+
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
+
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
+
*/
|
|
9
|
+
|
|
1
10
|
var __defProp = Object.defineProperty;
|
|
2
11
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
12
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
@@ -24,22 +33,11 @@ var import_acl = require("@nocobase/acl");
|
|
|
24
33
|
var import_database = require("@nocobase/database");
|
|
25
34
|
class RoleResourceModel extends import_database.Model {
|
|
26
35
|
async revoke(options) {
|
|
27
|
-
const { role, resourceName
|
|
36
|
+
const { role, resourceName } = options;
|
|
28
37
|
role.revokeResource(resourceName);
|
|
29
|
-
const targetActions = grantHelper.resourceTargetActionMap.get(`${role.name}.${resourceName}`) || [];
|
|
30
|
-
for (const targetAction of targetActions) {
|
|
31
|
-
const targetActionResource = (grantHelper.targetActionResourceMap.get(targetAction) || []).filter(
|
|
32
|
-
(item) => `${role.name}.${resourceName}` !== item
|
|
33
|
-
);
|
|
34
|
-
grantHelper.targetActionResourceMap.set(targetAction, targetActionResource);
|
|
35
|
-
if (targetActionResource.length == 0) {
|
|
36
|
-
role.revokeAction(targetAction);
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
grantHelper.resourceTargetActionMap.set(`${role.name}.${resourceName}`, []);
|
|
40
38
|
}
|
|
41
39
|
async writeToACL(options) {
|
|
42
|
-
const { acl
|
|
40
|
+
const { acl } = options;
|
|
43
41
|
const resourceName = this.get("name");
|
|
44
42
|
const roleName = this.get("roleName");
|
|
45
43
|
const role = acl.getRole(roleName);
|
|
@@ -47,7 +45,7 @@ class RoleResourceModel extends import_database.Model {
|
|
|
47
45
|
console.log(`${roleName} role does not exist`);
|
|
48
46
|
return;
|
|
49
47
|
}
|
|
50
|
-
await this.revoke({ role, resourceName
|
|
48
|
+
await this.revoke({ role, resourceName });
|
|
51
49
|
if (this.usingActionsConfig === false) {
|
|
52
50
|
return;
|
|
53
51
|
}
|
|
@@ -63,9 +61,7 @@ class RoleResourceModel extends import_database.Model {
|
|
|
63
61
|
await action.writeToACL({
|
|
64
62
|
acl,
|
|
65
63
|
role,
|
|
66
|
-
resourceName
|
|
67
|
-
associationFieldsActions,
|
|
68
|
-
grantHelper: options.grantHelper
|
|
64
|
+
resourceName
|
|
69
65
|
});
|
|
70
66
|
}
|
|
71
67
|
}
|
package/dist/server/server.d.ts
CHANGED
|
@@ -1,30 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file is part of the NocoBase (R) project.
|
|
3
|
+
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
+
* Authors: NocoBase Team.
|
|
5
|
+
*
|
|
6
|
+
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
+
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
+
*/
|
|
9
|
+
import { Transaction } from '@nocobase/database';
|
|
1
10
|
import { Plugin } from '@nocobase/server';
|
|
2
11
|
import { RoleModel } from './model/RoleModel';
|
|
3
12
|
import { RoleResourceActionModel } from './model/RoleResourceActionModel';
|
|
4
13
|
import { RoleResourceModel } from './model/RoleResourceModel';
|
|
5
|
-
export interface AssociationFieldAction {
|
|
6
|
-
associationActions: string[];
|
|
7
|
-
targetActions?: string[];
|
|
8
|
-
}
|
|
9
|
-
interface AssociationFieldActions {
|
|
10
|
-
[availableActionName: string]: AssociationFieldAction;
|
|
11
|
-
}
|
|
12
|
-
export interface AssociationFieldsActions {
|
|
13
|
-
[associationType: string]: AssociationFieldActions;
|
|
14
|
-
}
|
|
15
|
-
export declare class GrantHelper {
|
|
16
|
-
resourceTargetActionMap: Map<string, string[]>;
|
|
17
|
-
targetActionResourceMap: Map<string, string[]>;
|
|
18
|
-
constructor();
|
|
19
|
-
}
|
|
20
14
|
export declare class PluginACLServer extends Plugin {
|
|
21
|
-
associationFieldsActions: AssociationFieldsActions;
|
|
22
|
-
grantHelper: GrantHelper;
|
|
23
15
|
get acl(): import("@nocobase/acl").ACL;
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
writeResourceToACL(resourceModel: RoleResourceModel, transaction: any): Promise<void>;
|
|
27
|
-
writeActionToACL(actionModel: RoleResourceActionModel, transaction: any): Promise<void>;
|
|
16
|
+
writeResourceToACL(resourceModel: RoleResourceModel, transaction: Transaction): Promise<void>;
|
|
17
|
+
writeActionToACL(actionModel: RoleResourceActionModel, transaction: Transaction): Promise<void>;
|
|
28
18
|
writeRolesToACL(options: any): Promise<void>;
|
|
29
19
|
writeRoleToACL(role: RoleModel, options?: any): Promise<void>;
|
|
30
20
|
beforeLoad(): Promise<void>;
|
package/dist/server/server.js
CHANGED
|
@@ -1,3 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file is part of the NocoBase (R) project.
|
|
3
|
+
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
+
* Authors: NocoBase Team.
|
|
5
|
+
*
|
|
6
|
+
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
+
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
+
*/
|
|
9
|
+
|
|
1
10
|
var __create = Object.create;
|
|
2
11
|
var __defProp = Object.defineProperty;
|
|
3
12
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
@@ -27,7 +36,6 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
27
36
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
37
|
var server_exports = {};
|
|
29
38
|
__export(server_exports, {
|
|
30
|
-
GrantHelper: () => GrantHelper,
|
|
31
39
|
PluginACLServer: () => PluginACLServer,
|
|
32
40
|
default: () => server_default
|
|
33
41
|
});
|
|
@@ -47,74 +55,14 @@ var import_with_acl_meta = require("./middlewares/with-acl-meta");
|
|
|
47
55
|
var import_RoleModel = require("./model/RoleModel");
|
|
48
56
|
var import_RoleResourceActionModel = require("./model/RoleResourceActionModel");
|
|
49
57
|
var import_RoleResourceModel = require("./model/RoleResourceModel");
|
|
50
|
-
class GrantHelper {
|
|
51
|
-
resourceTargetActionMap = /* @__PURE__ */ new Map();
|
|
52
|
-
targetActionResourceMap = /* @__PURE__ */ new Map();
|
|
53
|
-
constructor() {
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
58
|
class PluginACLServer extends import_server.Plugin {
|
|
57
|
-
// association field actions config
|
|
58
|
-
associationFieldsActions = {};
|
|
59
|
-
grantHelper = new GrantHelper();
|
|
60
59
|
get acl() {
|
|
61
60
|
return this.app.acl;
|
|
62
61
|
}
|
|
63
|
-
registerAssociationFieldAction(associationType, value) {
|
|
64
|
-
this.associationFieldsActions[associationType] = value;
|
|
65
|
-
}
|
|
66
|
-
registerAssociationFieldsActions() {
|
|
67
|
-
this.registerAssociationFieldAction("hasOne", {
|
|
68
|
-
view: {
|
|
69
|
-
associationActions: ["list", "get", "view"]
|
|
70
|
-
},
|
|
71
|
-
create: {
|
|
72
|
-
associationActions: ["create", "set"]
|
|
73
|
-
},
|
|
74
|
-
update: {
|
|
75
|
-
associationActions: ["update", "remove", "set"]
|
|
76
|
-
}
|
|
77
|
-
});
|
|
78
|
-
this.registerAssociationFieldAction("hasMany", {
|
|
79
|
-
view: {
|
|
80
|
-
associationActions: ["list", "get", "view"]
|
|
81
|
-
},
|
|
82
|
-
create: {
|
|
83
|
-
associationActions: ["create", "set", "add"]
|
|
84
|
-
},
|
|
85
|
-
update: {
|
|
86
|
-
associationActions: ["update", "remove", "set"]
|
|
87
|
-
}
|
|
88
|
-
});
|
|
89
|
-
this.registerAssociationFieldAction("belongsTo", {
|
|
90
|
-
view: {
|
|
91
|
-
associationActions: ["list", "get", "view"]
|
|
92
|
-
},
|
|
93
|
-
create: {
|
|
94
|
-
associationActions: ["create", "set"]
|
|
95
|
-
},
|
|
96
|
-
update: {
|
|
97
|
-
associationActions: ["update", "remove", "set"]
|
|
98
|
-
}
|
|
99
|
-
});
|
|
100
|
-
this.registerAssociationFieldAction("belongsToMany", {
|
|
101
|
-
view: {
|
|
102
|
-
associationActions: ["list", "get", "view"]
|
|
103
|
-
},
|
|
104
|
-
create: {
|
|
105
|
-
associationActions: ["create", "set", "add"]
|
|
106
|
-
},
|
|
107
|
-
update: {
|
|
108
|
-
associationActions: ["update", "remove", "set", "toggle"]
|
|
109
|
-
}
|
|
110
|
-
});
|
|
111
|
-
}
|
|
112
62
|
async writeResourceToACL(resourceModel, transaction) {
|
|
113
63
|
await resourceModel.writeToACL({
|
|
114
64
|
acl: this.acl,
|
|
115
|
-
|
|
116
|
-
transaction,
|
|
117
|
-
grantHelper: this.grantHelper
|
|
65
|
+
transaction
|
|
118
66
|
});
|
|
119
67
|
}
|
|
120
68
|
async writeActionToACL(actionModel, transaction) {
|
|
@@ -123,9 +71,7 @@ class PluginACLServer extends import_server.Plugin {
|
|
|
123
71
|
await actionModel.writeToACL({
|
|
124
72
|
acl: this.acl,
|
|
125
73
|
role,
|
|
126
|
-
resourceName: resource.get("name")
|
|
127
|
-
associationFieldsActions: this.associationFieldsActions,
|
|
128
|
-
grantHelper: this.grantHelper
|
|
74
|
+
resourceName: resource.get("name")
|
|
129
75
|
});
|
|
130
76
|
}
|
|
131
77
|
async writeRolesToACL(options) {
|
|
@@ -587,6 +533,5 @@ class PluginACLServer extends import_server.Plugin {
|
|
|
587
533
|
var server_default = PluginACLServer;
|
|
588
534
|
// Annotate the CommonJS export names for ESM import in node:
|
|
589
535
|
0 && (module.exports = {
|
|
590
|
-
GrantHelper,
|
|
591
536
|
PluginACLServer
|
|
592
537
|
});
|
package/dist/swagger/index.d.ts
CHANGED
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file is part of the NocoBase (R) project.
|
|
3
|
+
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
+
* Authors: NocoBase Team.
|
|
5
|
+
*
|
|
6
|
+
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
+
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
+
*/
|
|
1
9
|
declare const _default: {
|
|
2
10
|
openapi: string;
|
|
3
11
|
info: {
|
package/dist/swagger/index.js
CHANGED
|
@@ -1,3 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file is part of the NocoBase (R) project.
|
|
3
|
+
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
+
* Authors: NocoBase Team.
|
|
5
|
+
*
|
|
6
|
+
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
+
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
+
*/
|
|
9
|
+
|
|
1
10
|
var __defProp = Object.defineProperty;
|
|
2
11
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
12
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"displayName.zh-CN": "权限控制",
|
|
5
5
|
"description": "Based on roles, resources, and actions, access control can precisely manage interface configuration permissions, data operation permissions, menu access permissions, and plugin permissions.",
|
|
6
6
|
"description.zh-CN": "基于角色、资源和操作的权限控制,可以精确控制界面配置权限、数据操作权限、菜单访问权限、插件权限。",
|
|
7
|
-
"version": "0.
|
|
7
|
+
"version": "1.0.0-alpha.10",
|
|
8
8
|
"license": "AGPL-3.0",
|
|
9
9
|
"main": "./dist/server/index.js",
|
|
10
10
|
"homepage": "https://docs.nocobase.com/handbook/acl",
|
|
@@ -20,19 +20,19 @@
|
|
|
20
20
|
"react-dom": "^18.2.0"
|
|
21
21
|
},
|
|
22
22
|
"peerDependencies": {
|
|
23
|
-
"@nocobase/acl": "
|
|
24
|
-
"@nocobase/actions": "
|
|
25
|
-
"@nocobase/cache": "
|
|
26
|
-
"@nocobase/client": "
|
|
27
|
-
"@nocobase/database": "
|
|
28
|
-
"@nocobase/server": "
|
|
29
|
-
"@nocobase/test": "
|
|
30
|
-
"@nocobase/utils": "
|
|
23
|
+
"@nocobase/acl": "1.x",
|
|
24
|
+
"@nocobase/actions": "1.x",
|
|
25
|
+
"@nocobase/cache": "1.x",
|
|
26
|
+
"@nocobase/client": "1.x",
|
|
27
|
+
"@nocobase/database": "1.x",
|
|
28
|
+
"@nocobase/server": "1.x",
|
|
29
|
+
"@nocobase/test": "1.x",
|
|
30
|
+
"@nocobase/utils": "1.x"
|
|
31
31
|
},
|
|
32
32
|
"repository": {
|
|
33
33
|
"type": "git",
|
|
34
34
|
"url": "git+https://github.com/nocobase/nocobase.git",
|
|
35
35
|
"directory": "packages/plugins/acl"
|
|
36
36
|
},
|
|
37
|
-
"gitHead": "
|
|
37
|
+
"gitHead": "39c634c88f835f8eadedf72ca11a9fb3323a50f8"
|
|
38
38
|
}
|