@openinc/parse-server-opendash 3.14.3 → 3.14.5
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/hooks/Permission.js +9 -0
- package/dist/index.js +9 -1
- package/package.json +1 -1
package/dist/hooks/Permission.js
CHANGED
|
@@ -3,9 +3,18 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.init = init;
|
|
4
4
|
const __1 = require("..");
|
|
5
5
|
const types_1 = require("../types");
|
|
6
|
+
const masterKeyPermission = [
|
|
7
|
+
"opendash:can-admin-tenants",
|
|
8
|
+
"opendash:tenant:change-tag-prefix",
|
|
9
|
+
"opendash:source:write-tag-ignore-tenant-prefix",
|
|
10
|
+
"opendash:source:write-tag-group",
|
|
11
|
+
];
|
|
6
12
|
async function init() {
|
|
7
13
|
(0, __1.beforeSaveHook)(types_1.Permission, async (request) => {
|
|
8
14
|
const { object, original, user } = request;
|
|
15
|
+
if (masterKeyPermission.includes(object.get("key")) && !request.master) {
|
|
16
|
+
throw new Parse.Error(Parse.Error.OPERATION_FORBIDDEN, `User is not allowed to create or update permission with key '${object.get("key")}' without master key`);
|
|
17
|
+
}
|
|
9
18
|
await (0, __1.defaultHandler)(request);
|
|
10
19
|
await (0, __1.defaultAclHandler)(request, {
|
|
11
20
|
allowCustomACL: true,
|
package/dist/index.js
CHANGED
|
@@ -403,7 +403,15 @@ async function defaultHandler(request) {
|
|
|
403
403
|
const user = (await request.user?.fetch({
|
|
404
404
|
useMasterKey: true,
|
|
405
405
|
}));
|
|
406
|
-
|
|
406
|
+
try {
|
|
407
|
+
await requirePermission(request, "opendash:can-admin-tenants", "User is not allowed to use tag which ignores tenant prefix");
|
|
408
|
+
if (!request.object.get("tenant")) {
|
|
409
|
+
request.object.set("tenant", user.get("tenant"));
|
|
410
|
+
}
|
|
411
|
+
}
|
|
412
|
+
catch (error) {
|
|
413
|
+
request.object.set("tenant", user.get("tenant"));
|
|
414
|
+
}
|
|
407
415
|
}
|
|
408
416
|
}
|
|
409
417
|
}
|