Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.
TypeScript acmeagentsai-agentscertificate-managementdevsecopsenvironment-variableskubernetesopen-sourcepampkipostgresprivate-caprivileged-access-managementsecret-managementsecret-managersecretssecrets-managementsecuritysecurity-toolsvault
Feat: Request access
Daniel Hougaardeca36f19934e
diff --git a/backend/src/ee/services/access-approval-policy/access-approval-policy-fns.ts b/backend/src/ee/services/access-approval-policy/access-approval-policy-fns.tsnew file mode 100644index 0000000000..b570c32fa1--- /dev/null+++ b/backend/src/ee/services/access-approval-policy/access-approval-policy-fns.ts@@ -0,0 +1,37 @@+import { ForbiddenError, subject } from "@casl/ability";++import { BadRequestError } from "@app/lib/errors";+import { ActorType } from "@app/services/auth/auth-type";++import { ProjectPermissionActions, ProjectPermissionSub } from "../permission/project-permission";+import { TVerifyApprovers } from "./access-approval-policy-types";++export const verifyApprovers = async ({+ approverProjectMemberships,+ projectId,+ orgId,+ envSlug,+ actorAuthMethod,+ secretPath,+ permissionService+}: TVerifyApprovers) => {+ for (const approver of approverProjectMemberships) {+ try {+ // eslint-disable-next-line no-await-in-loop+ const { permission: approverPermission } = await permissionService.getProjectPermission(+ ActorType.USER,+ approver.userId,+ projectId,+ actorAuthMethod,+ orgId+ );++ ForbiddenError.from(approverPermission).throwUnlessCan(+ ProjectPermissionActions.Create,+ subject(ProjectPermissionSub.Secrets, { environment: envSlug, secretPath })+ );+ } catch (err) {+ throw new BadRequestError({ message: "One or more approvers doesn't have access to be specified secret path" });+ }+ }+};