@budibase/backend-core 2.10.16-alpha.0 → 2.10.16-alpha.1
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/index.js +22 -11
- package/dist/index.js.map +2 -2
- package/dist/index.js.meta.json +1 -1
- package/dist/package.json +4 -4
- package/dist/src/security/permissions.d.ts +1 -1
- package/dist/src/security/permissions.js +6 -2
- package/dist/src/security/permissions.js.map +1 -1
- package/dist/src/security/roles.d.ts +4 -5
- package/dist/src/security/roles.js +19 -9
- package/dist/src/security/roles.js.map +1 -1
- package/package.json +4 -4
- package/src/security/permissions.ts +7 -2
- package/src/security/roles.ts +16 -11
package/dist/index.js
CHANGED
|
@@ -10561,12 +10561,14 @@ __export(roles_exports, {
|
|
|
10561
10561
|
RoleIDVersion: () => RoleIDVersion,
|
|
10562
10562
|
builtinRoleToNumber: () => builtinRoleToNumber,
|
|
10563
10563
|
checkForRoleResourceArray: () => checkForRoleResourceArray,
|
|
10564
|
+
getAllRoleIds: () => getAllRoleIds,
|
|
10564
10565
|
getAllRoles: () => getAllRoles,
|
|
10565
10566
|
getBuiltinRoles: () => getBuiltinRoles,
|
|
10566
10567
|
getDBRoleID: () => getDBRoleID,
|
|
10567
10568
|
getExternalRoleID: () => getExternalRoleID,
|
|
10568
10569
|
getRole: () => getRole,
|
|
10569
10570
|
getUserRoleHierarchy: () => getUserRoleHierarchy,
|
|
10571
|
+
getUserRoleIdHierarchy: () => getUserRoleIdHierarchy,
|
|
10570
10572
|
isBuiltin: () => isBuiltin,
|
|
10571
10573
|
lowerBuiltinRoleID: () => lowerBuiltinRoleID,
|
|
10572
10574
|
roleToNumber: () => roleToNumber
|
|
@@ -10590,9 +10592,9 @@ __export(permissions_exports, {
|
|
|
10590
10592
|
levelToNumber: () => levelToNumber
|
|
10591
10593
|
});
|
|
10592
10594
|
init_src();
|
|
10593
|
-
init_src();
|
|
10594
10595
|
var import_flatten = __toESM(require("lodash/flatten"));
|
|
10595
10596
|
var import_cloneDeep = __toESM(require("lodash/fp/cloneDeep"));
|
|
10597
|
+
init_src();
|
|
10596
10598
|
var Permission = class {
|
|
10597
10599
|
constructor(type, level) {
|
|
10598
10600
|
this.type = type;
|
|
@@ -10651,7 +10653,8 @@ var BUILTIN_PERMISSIONS = {
|
|
|
10651
10653
|
name: "Read only",
|
|
10652
10654
|
permissions: [
|
|
10653
10655
|
new Permission("query" /* QUERY */, "read" /* READ */),
|
|
10654
|
-
new Permission("table" /* TABLE */, "read" /* READ */)
|
|
10656
|
+
new Permission("table" /* TABLE */, "read" /* READ */),
|
|
10657
|
+
new Permission("app" /* APP */, "read" /* READ */)
|
|
10655
10658
|
]
|
|
10656
10659
|
},
|
|
10657
10660
|
WRITE: {
|
|
@@ -10661,7 +10664,8 @@ var BUILTIN_PERMISSIONS = {
|
|
|
10661
10664
|
new Permission("query" /* QUERY */, "write" /* WRITE */),
|
|
10662
10665
|
new Permission("table" /* TABLE */, "write" /* WRITE */),
|
|
10663
10666
|
new Permission("automation" /* AUTOMATION */, "execute" /* EXECUTE */),
|
|
10664
|
-
new Permission("legacy_view" /* LEGACY_VIEW */, "read" /* READ */)
|
|
10667
|
+
new Permission("legacy_view" /* LEGACY_VIEW */, "read" /* READ */),
|
|
10668
|
+
new Permission("app" /* APP */, "read" /* READ */)
|
|
10665
10669
|
]
|
|
10666
10670
|
},
|
|
10667
10671
|
POWER: {
|
|
@@ -10672,7 +10676,8 @@ var BUILTIN_PERMISSIONS = {
|
|
|
10672
10676
|
new Permission("user" /* USER */, "read" /* READ */),
|
|
10673
10677
|
new Permission("automation" /* AUTOMATION */, "execute" /* EXECUTE */),
|
|
10674
10678
|
new Permission("webhook" /* WEBHOOK */, "read" /* READ */),
|
|
10675
|
-
new Permission("legacy_view" /* LEGACY_VIEW */, "read" /* READ */)
|
|
10679
|
+
new Permission("legacy_view" /* LEGACY_VIEW */, "read" /* READ */),
|
|
10680
|
+
new Permission("app" /* APP */, "read" /* READ */)
|
|
10676
10681
|
]
|
|
10677
10682
|
},
|
|
10678
10683
|
ADMIN: {
|
|
@@ -10684,7 +10689,8 @@ var BUILTIN_PERMISSIONS = {
|
|
|
10684
10689
|
new Permission("automation" /* AUTOMATION */, "admin" /* ADMIN */),
|
|
10685
10690
|
new Permission("webhook" /* WEBHOOK */, "read" /* READ */),
|
|
10686
10691
|
new Permission("query" /* QUERY */, "admin" /* ADMIN */),
|
|
10687
|
-
new Permission("legacy_view" /* LEGACY_VIEW */, "read" /* READ */)
|
|
10692
|
+
new Permission("legacy_view" /* LEGACY_VIEW */, "read" /* READ */),
|
|
10693
|
+
new Permission("app" /* APP */, "read" /* READ */)
|
|
10688
10694
|
]
|
|
10689
10695
|
}
|
|
10690
10696
|
};
|
|
@@ -10870,9 +10876,12 @@ async function getAllUserRoles(userRoleId) {
|
|
|
10870
10876
|
}
|
|
10871
10877
|
return roles;
|
|
10872
10878
|
}
|
|
10873
|
-
async function
|
|
10874
|
-
const roles = await
|
|
10875
|
-
return
|
|
10879
|
+
async function getUserRoleIdHierarchy(userRoleId) {
|
|
10880
|
+
const roles = await getUserRoleHierarchy(userRoleId);
|
|
10881
|
+
return roles.map((role) => role._id);
|
|
10882
|
+
}
|
|
10883
|
+
async function getUserRoleHierarchy(userRoleId) {
|
|
10884
|
+
return getAllUserRoles(userRoleId);
|
|
10876
10885
|
}
|
|
10877
10886
|
function checkForRoleResourceArray(rolePerms, resourceId) {
|
|
10878
10887
|
if (rolePerms && !Array.isArray(rolePerms[resourceId])) {
|
|
@@ -10884,6 +10893,10 @@ function checkForRoleResourceArray(rolePerms, resourceId) {
|
|
|
10884
10893
|
}
|
|
10885
10894
|
return rolePerms;
|
|
10886
10895
|
}
|
|
10896
|
+
async function getAllRoleIds(appId) {
|
|
10897
|
+
const roles = await getAllRoles(appId);
|
|
10898
|
+
return roles.map((role) => role._id);
|
|
10899
|
+
}
|
|
10887
10900
|
async function getAllRoles(appId) {
|
|
10888
10901
|
if (appId) {
|
|
10889
10902
|
return doWithDB(appId, internal);
|
|
@@ -10946,9 +10959,7 @@ var AccessController = class {
|
|
|
10946
10959
|
}
|
|
10947
10960
|
let roleIds = userRoleId ? this.userHierarchies[userRoleId] : null;
|
|
10948
10961
|
if (!roleIds && userRoleId) {
|
|
10949
|
-
roleIds = await
|
|
10950
|
-
idOnly: true
|
|
10951
|
-
});
|
|
10962
|
+
roleIds = await getUserRoleIdHierarchy(userRoleId);
|
|
10952
10963
|
this.userHierarchies[userRoleId] = roleIds;
|
|
10953
10964
|
}
|
|
10954
10965
|
return roleIds?.indexOf(tryingRoleId) !== -1;
|