@7365admin1/core 3.57.0 → 3.58.0
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/CHANGELOG.md +17 -0
- package/dist/index.d.ts +3 -3
- package/dist/index.js +22 -6
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +22 -6
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/test/e2e/role-template-restore.e2e.test.mjs +369 -0
- package/test/role-scope-separation.test.mjs +149 -0
- package/test/role-scope.test.mjs +15 -3
package/dist/index.mjs
CHANGED
|
@@ -18735,9 +18735,14 @@ function requireNoPlatformGrant(role, next) {
|
|
|
18735
18735
|
"These are Seven365 console permissions and cannot be granted on a client role: " + added.join(", ")
|
|
18736
18736
|
);
|
|
18737
18737
|
}
|
|
18738
|
-
function
|
|
18738
|
+
function permissionsMeanEverything(permissions) {
|
|
18739
|
+
return !permissions?.length || permissions.includes("*");
|
|
18740
|
+
}
|
|
18741
|
+
function refuseSharedClientTemplate(role, next) {
|
|
18739
18742
|
if (roleScope(role) !== "client-template")
|
|
18740
|
-
return;
|
|
18743
|
+
return false;
|
|
18744
|
+
if (Array.isArray(next) && permissionsMeanEverything(next))
|
|
18745
|
+
return true;
|
|
18741
18746
|
throw new UnauthorizedError4(
|
|
18742
18747
|
"This role is shared by every client that was invited with it and cannot be changed here."
|
|
18743
18748
|
);
|
|
@@ -18757,9 +18762,16 @@ async function requireRoleRead(req, roleId, org) {
|
|
|
18757
18762
|
return;
|
|
18758
18763
|
await requireRoleOrg(req, org);
|
|
18759
18764
|
}
|
|
18760
|
-
async function requireRoleWrite(req, role) {
|
|
18761
|
-
refuseSharedClientTemplate(role);
|
|
18765
|
+
async function requireRoleWrite(req, role, next) {
|
|
18766
|
+
const isTemplateRestore = refuseSharedClientTemplate(role, next);
|
|
18762
18767
|
await requireRoleOrg(req, role?.org);
|
|
18768
|
+
return isTemplateRestore;
|
|
18769
|
+
}
|
|
18770
|
+
function logTemplateRestore(req, roleId, before, after) {
|
|
18771
|
+
logger25.log({
|
|
18772
|
+
level: "warn",
|
|
18773
|
+
message: `SHARED CLIENT TEMPLATE RESTORED TO ALLOW-ALL. actor=${callerId(req) || "unknown"} role=${roleId} before=${(before ?? []).length} permission(s) after=${JSON.stringify(after)}`
|
|
18774
|
+
});
|
|
18763
18775
|
}
|
|
18764
18776
|
function useRoleController() {
|
|
18765
18777
|
const {
|
|
@@ -18905,9 +18917,11 @@ function useRoleController() {
|
|
|
18905
18917
|
const existing = await _getRoleById(_id);
|
|
18906
18918
|
if (!existing)
|
|
18907
18919
|
throw new NotFoundError14("Role not found.");
|
|
18908
|
-
await requireRoleWrite(req, existing);
|
|
18920
|
+
const isRestore = await requireRoleWrite(req, existing, permissions);
|
|
18909
18921
|
requireNoPlatformGrant(existing, permissions);
|
|
18910
18922
|
const role = await _updateRole(_id, { name, permissions });
|
|
18923
|
+
if (isRestore)
|
|
18924
|
+
logTemplateRestore(req, _id, existing?.permissions, permissions);
|
|
18911
18925
|
res.json({ message: "Successfully updated role.", data: { role } });
|
|
18912
18926
|
return;
|
|
18913
18927
|
} catch (error2) {
|
|
@@ -18934,9 +18948,11 @@ function useRoleController() {
|
|
|
18934
18948
|
const existing = await _getRoleById(_id);
|
|
18935
18949
|
if (!existing)
|
|
18936
18950
|
throw new NotFoundError14("Role not found.");
|
|
18937
|
-
await requireRoleWrite(req, existing);
|
|
18951
|
+
const isRestore = await requireRoleWrite(req, existing, permissions);
|
|
18938
18952
|
requireNoPlatformGrant(existing, permissions);
|
|
18939
18953
|
await _updatePermissionsById(_id, permissions);
|
|
18954
|
+
if (isRestore)
|
|
18955
|
+
logTemplateRestore(req, _id, existing?.permissions, permissions);
|
|
18940
18956
|
res.json({ message: "Successfully updated role permissions." });
|
|
18941
18957
|
return;
|
|
18942
18958
|
} catch (error2) {
|