rbac and licenses

This commit is contained in:
root
2026-05-01 22:37:21 +02:00
parent e208ef1759
commit f09f148aea
14 changed files with 326 additions and 80 deletions

View File

@@ -63,7 +63,6 @@ module.exports = startMenuItems = async function (app, objectGuid) {
plugin.menu.items = (plugin.menu.items || []).map(item => {
const resource = item.label;
const requiredPermissions = item.permissions || [];
const debugTrace = [];
@@ -77,25 +76,25 @@ module.exports = startMenuItems = async function (app, objectGuid) {
const scopeMatch =
userPerm.scope === required.scope;
const resourceMatch =
!userPerm.resource ||
userPerm.resource === 'ALL' ||
userPerm.resource === required.resource;
const actionMatch =
userPerm.action === 'ALL' ||
userPerm.action === required.action ||
required.action === 'ALL';
const resourceMatch =
!userPerm.resource ||
userPerm.resource === 'ALL' ||
userPerm.resource === resource;
const result = scopeMatch && actionMatch && resourceMatch;
const result = scopeMatch && resourceMatch && actionMatch;
if (debug) {
debugTrace.push({
userPerm,
required,
scopeMatch,
actionMatch,
resourceMatch,
actionMatch,
result
});
}
@@ -105,7 +104,7 @@ module.exports = startMenuItems = async function (app, objectGuid) {
});
if (debug) {
log(`\nMENU ITEM: ${item.label} - AUTHORIZED:', ${authorized} - TRACE:', ${debugTrace}`);
log(`\nMENU ITEM: ${item.label} - AUTHORIZED:', ${authorized} - TRACE:', ${JSON.stringify(debugTrace)}`);
}
return {