1
0
Fork 0
mirror of synced 2024-10-03 19:43:32 +13:00

Merge pull request #11675 from Budibase/fix/integration_tests

Fix permission sdk usage on auth middleware
This commit is contained in:
Adria Navarro 2023-09-06 10:07:03 +02:00 committed by GitHub
commit 4af4587091
2 changed files with 6 additions and 16 deletions

View file

@ -380,8 +380,8 @@ export function getDBRoleID(roleName: string) {
export function getExternalRoleID(roleId: string, version?: string) { export function getExternalRoleID(roleId: string, version?: string) {
// for built-in roles we want to remove the DB role ID element (role_) // for built-in roles we want to remove the DB role ID element (role_)
if ( if (
(roleId.startsWith(DocumentType.ROLE) && isBuiltin(roleId)) || roleId.startsWith(DocumentType.ROLE) &&
version === RoleIDVersion.NAME (isBuiltin(roleId) || version === RoleIDVersion.NAME)
) { ) {
return roleId.split(`${DocumentType.ROLE}${SEPARATOR}`)[1] return roleId.split(`${DocumentType.ROLE}${SEPARATOR}`)[1]
} }

View file

@ -1,18 +1,13 @@
import { context, db, env, roles } from "@budibase/backend-core" import { db, env, roles } from "@budibase/backend-core"
import { features } from "@budibase/pro" import { features } from "@budibase/pro"
import { import {
DocumentType, DocumentType,
PermissionLevel, PermissionLevel,
PermissionSource, PermissionSource,
PlanType, PlanType,
Role,
VirtualDocumentType, VirtualDocumentType,
} from "@budibase/types" } from "@budibase/types"
import { import { extractViewInfoFromID, isViewID } from "../../../db/utils"
extractViewInfoFromID,
getRoleParams,
isViewID,
} from "../../../db/utils"
import { import {
CURRENTLY_SUPPORTED_LEVELS, CURRENTLY_SUPPORTED_LEVELS,
getBasePermissions, getBasePermissions,
@ -84,13 +79,8 @@ export async function allowsExplicitPermissions(resourceId: string) {
export async function getResourcePerms( export async function getResourcePerms(
resourceId: string resourceId: string
): Promise<ResourcePermissions> { ): Promise<ResourcePermissions> {
const db = context.getAppDB() const rolesList = await roles.getAllRoles()
const body = await db.allDocs(
getRoleParams(null, {
include_docs: true,
})
)
const rolesList = body.rows.map<Role>(row => row.doc)
let permissions: ResourcePermissions = {} let permissions: ResourcePermissions = {}
const permsToInherit = await getInheritablePermissions(resourceId) const permsToInherit = await getInheritablePermissions(resourceId)