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
improvement(pam): surface approval policy presence in gate error details
bernie-g9a927443db2d
diff --git a/backend/src/ee/services/pam-session/pam-session-service.ts b/backend/src/ee/services/pam-session/pam-session-service.tsindex 9d42004ed3..e5d03abdfb 100644--- a/backend/src/ee/services/pam-session/pam-session-service.ts+++ b/backend/src/ee/services/pam-session/pam-session-service.ts@@ -88,7 +88,10 @@ type TPamSessionServiceFactoryDep = {"createMfaSession" | "getMfaSession" | "deleteMfaSession" | "sendMfaCode">;orgDAL: Pick<TOrgDALFactory, "findOrgById">;- pamAccessRequestService: Pick<TPamAccessRequestServiceFactory, "checkGrant" | "getAccessStatusBatch">;+ pamAccessRequestService: Pick<+ TPamAccessRequestServiceFactory,+ "checkGrant" | "getAccessStatusBatch" | "getFolderPolicyConfigured"+ >;};export type TPamSessionServiceFactory = ReturnType<typeof pamSessionServiceFactory>;@@ -417,17 +420,19 @@ export const pamSessionServiceFactory = ({projectId});if (!grant) {- // Distinguish "no request yet" from "request awaiting review" so the CLI can guide the- // user to their existing request instead of prompting into a duplicate-request error- const statusEntry = (- await pamAccessRequestService.getAccessStatusBatch(actor.actorId, [account.id], projectId)- ).get(account.id);+ // Distinguish "no request yet" from "request awaiting review" and from "folder has no+ // approvers", so the CLI can guide the user instead of prompting into a 400+ const [statusMap, foldersWithApprovalPolicy] = await Promise.all([+ pamAccessRequestService.getAccessStatusBatch(actor.actorId, [account.id], projectId),+ pamAccessRequestService.getFolderPolicyConfigured(account.folderId ? [account.folderId] : [])+ ]);throw new ForbiddenRequestError({name: "PAM_APPROVAL_REQUIRED",message: "Access request required",details: {requireReason: policy.requireReason,- hasPendingRequest: statusEntry?.accessStatus === PamAccessStatus.Pending+ hasPendingRequest: statusMap.get(account.id)?.accessStatus === PamAccessStatus.Pending,+ hasApprovalPolicy: Boolean(account.folderId && foldersWithApprovalPolicy.has(account.folderId))}});}