From 5f4694d4d8699a364c5a44dd41921f3bcbfa42b0 Mon Sep 17 00:00:00 2001 From: mike12345567 Date: Thu, 10 Oct 2024 16:13:32 +0100 Subject: [PATCH 1/2] Fix for an issue found with custom role naming. --- packages/backend-core/src/security/roles.ts | 4 +++- packages/server/src/api/routes/tests/role.spec.js | 6 +++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/packages/backend-core/src/security/roles.ts b/packages/backend-core/src/security/roles.ts index 65339832cf..fa2d114d7d 100644 --- a/packages/backend-core/src/security/roles.ts +++ b/packages/backend-core/src/security/roles.ts @@ -435,7 +435,9 @@ export function getExternalRoleID(roleId: string, version?: string) { roleId.startsWith(DocumentType.ROLE) && (isBuiltin(roleId) || version === RoleIDVersion.NAME) ) { - return roleId.split(`${DocumentType.ROLE}${SEPARATOR}`)[1] + const parts = roleId.split(SEPARATOR) + parts.shift() + return parts.join(SEPARATOR) } return roleId } diff --git a/packages/server/src/api/routes/tests/role.spec.js b/packages/server/src/api/routes/tests/role.spec.js index 4575f9b213..00025e396a 100644 --- a/packages/server/src/api/routes/tests/role.spec.js +++ b/packages/server/src/api/routes/tests/role.spec.js @@ -161,7 +161,7 @@ describe("/roles", () => { it("should not fetch higher level accessible roles when a custom role header is provided", async () => { await createRole({ - name: `CUSTOM_ROLE`, + name: `custom_role_1`, inherits: roles.BUILTIN_ROLE_IDS.BASIC, permissionId: permissions.BuiltinPermissionID.READ_ONLY, version: "name", @@ -170,11 +170,11 @@ describe("/roles", () => { .get("/api/roles/accessible") .set({ ...config.defaultHeaders(), - "x-budibase-role": "CUSTOM_ROLE", + "x-budibase-role": "custom_role_1", }) .expect(200) expect(res.body.length).toBe(3) - expect(res.body[0]).toBe("CUSTOM_ROLE") + expect(res.body[0]).toBe("custom_role_1") expect(res.body[1]).toBe("BASIC") expect(res.body[2]).toBe("PUBLIC") }) From a1e55a5324fbf2917553a6bb235631b1c8abbfec Mon Sep 17 00:00:00 2001 From: Budibase Staging Release Bot <> Date: Thu, 10 Oct 2024 15:28:36 +0000 Subject: [PATCH 2/2] Bump version to 2.32.16 --- lerna.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lerna.json b/lerna.json index 4d36affd04..ba3db109d0 100644 --- a/lerna.json +++ b/lerna.json @@ -1,6 +1,6 @@ { "$schema": "node_modules/lerna/schemas/lerna-schema.json", - "version": "2.32.15", + "version": "2.32.16", "npmClient": "yarn", "packages": [ "packages/*",