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
Minor fix on approveRequest permissions check
Carlos Monastyrski88951386bb66
diff --git a/backend/src/db/schemas/approval-policies.ts b/backend/src/db/schemas/approval-policies.tsindex 9cce81a914..2d9fe3f555 100644--- a/backend/src/db/schemas/approval-policies.ts+++ b/backend/src/db/schemas/approval-policies.ts@@ -17,9 +17,9 @@ export const ApprovalPoliciesSchema = z.object({maxRequestTtl: z.string().nullable().optional(),conditions: z.unknown(),constraints: z.unknown(),- bypassForMachineIdentities: z.boolean().default(false).nullable().optional(),createdAt: z.date(),- updatedAt: z.date()+ updatedAt: z.date(),+ bypassForMachineIdentities: z.boolean().default(false)});export type TApprovalPolicies = z.infer<typeof ApprovalPoliciesSchema>;diff --git a/backend/src/db/schemas/approval-requests.ts b/backend/src/db/schemas/approval-requests.tsindex 655fef3e4f..e93e684000 100644--- a/backend/src/db/schemas/approval-requests.ts+++ b/backend/src/db/schemas/approval-requests.ts@@ -13,7 +13,6 @@ export const ApprovalRequestsSchema = z.object({organizationId: z.string().uuid(),policyId: z.string().uuid().nullable().optional(),requesterId: z.string().uuid().nullable().optional(),- machineIdentityId: z.string().uuid().nullable().optional(),requesterName: z.string(),requesterEmail: z.string(),type: z.string(),@@ -23,7 +22,8 @@ export const ApprovalRequestsSchema = z.object({requestData: z.unknown(),expiresAt: z.date().nullable().optional(),createdAt: z.date(),- updatedAt: z.date()+ updatedAt: z.date(),+ machineIdentityId: z.string().uuid().nullable().optional()});export type TApprovalRequests = z.infer<typeof ApprovalRequestsSchema>;diff --git a/backend/src/db/schemas/certificate-requests.ts b/backend/src/db/schemas/certificate-requests.tsindex b64d691884..a0154f5be3 100644--- a/backend/src/db/schemas/certificate-requests.ts+++ b/backend/src/db/schemas/certificate-requests.ts@@ -19,7 +19,6 @@ export const CertificateRequestsSchema = z.object({csr: z.string().nullable().optional(),commonName: z.string().nullable().optional(),altNames: z.string().nullable().optional(),- altNamesJson: z.unknown().nullable().optional(),keyUsages: z.string().array().nullable().optional(),extendedKeyUsages: z.string().array().nullable().optional(),notBefore: z.date().nullable().optional(),@@ -31,14 +30,15 @@ export const CertificateRequestsSchema = z.object({acmeOrderId: z.string().uuid().nullable().optional(),basicConstraints: z.unknown().nullable().optional(),approvalRequestId: z.string().uuid().nullable().optional(),- ttl: z.string().nullable().optional(),- issuanceType: z.string().nullable().optional(),+ altNamesJson: z.unknown().nullable().optional(),enrollmentType: z.string().nullable().optional(),+ issuanceType: z.string().nullable().optional(),organization: z.string().nullable().optional(),organizationalUnit: z.string().nullable().optional(),country: z.string().nullable().optional(),state: z.string().nullable().optional(),- locality: z.string().nullable().optional()+ locality: z.string().nullable().optional(),+ ttl: z.string().nullable().optional()});export type TCertificateRequests = z.infer<typeof CertificateRequestsSchema>;diff --git a/backend/src/services/approval-policy/approval-policy-service.ts b/backend/src/services/approval-policy/approval-policy-service.tsindex 626ed6f2f6..ecd834c7c4 100644--- a/backend/src/services/approval-policy/approval-policy-service.ts+++ b/backend/src/services/approval-policy/approval-policy-service.ts@@ -12,6 +12,8 @@ import { BadRequestError, ForbiddenRequestError, NotFoundError } from "@app/lib/import { logger } from "@app/lib/logger";import { ms } from "@app/lib/ms";import { OrgServiceActor } from "@app/lib/types";+import { ActorType } from "@app/services/auth/auth-type";+import { EnrollmentType } from "@app/services/certificate-profile/certificate-profile-types";import { TCertificateRequestDALFactory } from "@app/services/certificate-request/certificate-request-dal";import { CertificateRequestStatus } from "@app/services/certificate-request/certificate-request-types";import { TCertificateV3ServiceFactory } from "@app/services/certificate-v3/certificate-v3-service";@@ -64,7 +66,7 @@ type TApprovalPolicyServiceFactoryDep = {permissionService: Pick<TPermissionServiceFactory, "getProjectPermission" | "getOrgPermission">;projectMembershipDAL: Pick<TProjectMembershipDALFactory, "findProjectMembershipsByUserIds">;certificateV3Service: Pick<TCertificateV3ServiceFactory, "issueCertificateFromApprovedRequest">;- certificateRequestDAL: Pick<TCertificateRequestDALFactory, "updateById">;+ certificateRequestDAL: Pick<TCertificateRequestDALFactory, "updateById" | "findById">;};export type TApprovalPolicyServiceFactory = ReturnType<typeof approvalPolicyServiceFactory>;@@ -687,12 +689,44 @@ export const approvalPolicyServiceFactory = ({});try {- await certificateV3Service.issueCertificateFromApprovedRequest(certReqId, {- actor: actor.type,- actorId: actor.id,- actorAuthMethod: actor.authMethod,- actorOrgId: actor.orgId- });+ const certRequest = await certificateRequestDAL.findById(certReqId);++ // For ACME/EST enrollment types, use the approver's context+ const isAutomatedEnrollment =+ certRequest?.enrollmentType === EnrollmentType.ACME || certRequest?.enrollmentType === EnrollmentType.EST;++ let actorContext: {+ actor: ActorType;+ actorId: string;+ actorAuthMethod: typeof actor.authMethod;+ actorOrgId: string;+ };++ if (isAutomatedEnrollment) {+ actorContext = {+ actor: actor.type,+ actorId: actor.id,+ actorAuthMethod: actor.authMethod,+ actorOrgId: actor.orgId+ };+ } else {+ // Use original requester's identity (stored in approval request) for API enrollment+ const originalRequesterActor = finalRequest.machineIdentityId ? ActorType.IDENTITY : ActorType.USER;+ const originalRequesterId = finalRequest.machineIdentityId || finalRequest.requesterId;++ if (!originalRequesterId) {+ throw new BadRequestError({ message: "Approval request is missing requester information" });+ }++ actorContext = {+ actor: originalRequesterActor,+ actorId: originalRequesterId,+ actorAuthMethod: actor.authMethod,+ actorOrgId: actor.orgId+ };+ }++ await certificateV3Service.issueCertificateFromApprovedRequest(certReqId, actorContext);logger.info({ certificateRequestId: certReqId, approvalRequestId: finalRequest.id },"Certificate issued after approval"