Skip to content

Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.

Fix ACME audit logs

Carlos Monastyrski8363ffe9c66a
diff --git a/backend/src/ee/routes/v1/pki-acme-router.ts b/backend/src/ee/routes/v1/pki-acme-router.ts
index a73f955ae0..cf99ad116b 100644
--- a/backend/src/ee/routes/v1/pki-acme-router.ts
+++ b/backend/src/ee/routes/v1/pki-acme-router.ts
@@ -158,7 +158,8 @@ export const registerPkiAcmeRouter = async (server: FastifyZodProvider) => {
profileId: req.params.profileId,
alg,
jwk: jwk!,
- payload
+ payload,
+ auditLogInfo: req.auditLogInfo
})
);
}
@@ -230,7 +231,8 @@ export const registerPkiAcmeRouter = async (server: FastifyZodProvider) => {
await server.services.pkiAcme.createAcmeOrder({
profileId,
accountId,
- payload
+ payload,
+ auditLogInfo: req.auditLogInfo
})
);
}
@@ -304,7 +306,8 @@ export const registerPkiAcmeRouter = async (server: FastifyZodProvider) => {
profileId,
accountId,
orderId: req.params.orderId,
- payload
+ payload,
+ auditLogInfo: req.auditLogInfo
})
);
}
@@ -373,7 +376,12 @@ export const registerPkiAcmeRouter = async (server: FastifyZodProvider) => {
return sendAcmeResponse(
res,
profileId,
- await server.services.pkiAcme.downloadAcmeCertificate({ profileId, accountId, orderId: req.params.orderId })
+ await server.services.pkiAcme.downloadAcmeCertificate({
+ profileId,
+ accountId,
+ orderId: req.params.orderId,
+ auditLogInfo: req.auditLogInfo
+ })
);
}
});
@@ -444,7 +452,8 @@ export const registerPkiAcmeRouter = async (server: FastifyZodProvider) => {
profileId,
accountId,
authzId: req.params.authzId,
- challengeId: req.params.challengeId
+ challengeId: req.params.challengeId,
+ auditLogInfo: req.auditLogInfo
})
);
}
diff --git a/backend/src/ee/services/pki-acme/pki-acme-service.ts b/backend/src/ee/services/pki-acme/pki-acme-service.ts
index 12aba4f5de..6cbcd0ca09 100644
--- a/backend/src/ee/services/pki-acme/pki-acme-service.ts
+++ b/backend/src/ee/services/pki-acme/pki-acme-service.ts
@@ -57,7 +57,7 @@ import { TKmsServiceFactory } from "@app/services/kms/kms-service";
import { TProjectDALFactory } from "@app/services/project/project-dal";
import { getProjectKmsCertificateKeyId } from "@app/services/project/project-fns";
-import { EventType, TAuditLogServiceFactory } from "../audit-log/audit-log-types";
+import { AuditLogInfo, EventType, TAuditLogServiceFactory } from "../audit-log/audit-log-types";
import { TPkiAcmeAccountDALFactory } from "./pki-acme-account-dal";
import { TPkiAcmeAuthDALFactory } from "./pki-acme-auth-dal";
import { TPkiAcmeChallengeDALFactory } from "./pki-acme-challenge-dal";
@@ -452,12 +452,14 @@ export const pkiAcmeServiceFactory = ({
profileId,
alg,
jwk,
- payload: { onlyReturnExisting, contact, externalAccountBinding }
+ payload: { onlyReturnExisting, contact, externalAccountBinding },
+ auditLogInfo
}: {
profileId: string;
alg: string;
jwk: JsonWebKey;
payload: TCreateAcmeAccountPayload;
+ auditLogInfo: AuditLogInfo;
}): Promise<TAcmeResponse<TCreateAcmeAccountResponse>> => {
const profile = await validateAcmeProfile(profileId);
const publicKeyThumbprint = await calculateJwkThumbprint(jwk, "sha256");
@@ -505,6 +507,7 @@ export const pkiAcmeServiceFactory = ({
}
if (existingAccount) {
await auditLogService.createAuditLog({
+ ...auditLogInfo,
projectId: profile.projectId,
actor: {
type: ActorType.ACME_PROFILE,
@@ -597,6 +600,7 @@ export const pkiAcmeServiceFactory = ({
});
await auditLogService.createAuditLog({
+ ...auditLogInfo,
projectId: profile.projectId,
actor: {
type: ActorType.ACME_PROFILE,
@@ -656,11 +660,13 @@ export const pkiAcmeServiceFactory = ({
const createAcmeOrder = async ({
profileId,
accountId,
- payload
+ payload,
+ auditLogInfo
}: {
profileId: string;
accountId: string;
payload: TCreateAcmeOrderPayload;
+ auditLogInfo: AuditLogInfo;
}): Promise<TAcmeResponse<TAcmeOrderResource>> => {
const profile = await validateAcmeProfile(profileId);
const skipDnsOwnershipVerification = profile.acmeConfig?.skipDnsOwnershipVerification ?? false;
@@ -745,6 +751,7 @@ export const pkiAcmeServiceFactory = ({
tx
);
await auditLogService.createAuditLog({
+ ...auditLogInfo,
projectId: profile.projectId,
actor: {
type: ActorType.ACME_ACCOUNT,
@@ -952,12 +959,14 @@ export const pkiAcmeServiceFactory = ({
profileId,
accountId,
orderId,
- payload
+ payload,
+ auditLogInfo
}: {
profileId: string;
accountId: string;
orderId: string;
payload: TFinalizeAcmeOrderPayload;
+ auditLogInfo: AuditLogInfo;
}): Promise<TAcmeResponse<TAcmeOrderResource>> => {
const profile = (await certificateProfileDAL.findByIdWithConfigs(profileId))!;
@@ -1243,6 +1252,7 @@ export const pkiAcmeServiceFactory = ({
}
order = updatedOrder;
await auditLogService.createAuditLog({
+ ...auditLogInfo,
projectId: profile.projectId,
actor: {
type: ActorType.ACME_ACCOUNT,
@@ -1275,11 +1285,13 @@ export const pkiAcmeServiceFactory = ({
const downloadAcmeCertificate = async ({
profileId,
accountId,
- orderId
+ orderId,
+ auditLogInfo
}: {
profileId: string;
accountId: string;
orderId: string;
+ auditLogInfo: AuditLogInfo;
}): Promise<TAcmeResponse<string>> => {
const profile = await validateAcmeProfile(profileId);
const order = await acmeOrderDAL.findByAccountAndOrderIdWithAuthorizations(accountId, orderId);
@@ -1318,6 +1330,7 @@ export const pkiAcmeServiceFactory = ({
const certChain = certificateChain.trim().replace("\n", "\r\n");
await auditLogService.createAuditLog({
+ ...auditLogInfo,
projectId: profile.projectId,
actor: {
type: ActorType.ACME_ACCOUNT,
@@ -1409,12 +1422,14 @@ export const pkiAcmeServiceFactory = ({
profileId,
accountId,
authzId,
- challengeId
+ challengeId,
+ auditLogInfo
}: {
profileId: string;
accountId: string;
authzId: string;
challengeId: string;
+ auditLogInfo: AuditLogInfo;
}): Promise<TAcmeResponse<TRespondToAcmeChallengeResponse>> => {
const profile = await validateAcmeProfile(profileId);
const result = await acmeChallengeDAL.findByAccountAuthAndChallengeId(accountId, authzId, challengeId);
@@ -1425,6 +1440,7 @@ export const pkiAcmeServiceFactory = ({
await pkiAcmeQueueService.queueChallengeValidation(challengeId);
const challenge = (await acmeChallengeDAL.findByIdForChallengeValidation(challengeId))!;
await auditLogService.createAuditLog({
+ ...auditLogInfo,
projectId: profile.projectId,
actor: {
type: ActorType.ACME_ACCOUNT,
diff --git a/backend/src/ee/services/pki-acme/pki-acme-types.ts b/backend/src/ee/services/pki-acme/pki-acme-types.ts
index 6607ce711b..b00adfd4c4 100644
--- a/backend/src/ee/services/pki-acme/pki-acme-types.ts
+++ b/backend/src/ee/services/pki-acme/pki-acme-types.ts
@@ -2,6 +2,7 @@ import { JWSHeaderParameters } from "jose";
import { z } from "zod";
import { TPkiAcmeChallenges } from "@app/db/schemas/pki-acme-challenges";
+import { AuditLogInfo } from "@app/ee/services/audit-log/audit-log-types";
import {
AcmeOrderResourceSchema,
@@ -94,12 +95,14 @@ export type TPkiAcmeServiceFactory = {
profileId,
alg,
jwk,
- payload
+ payload,
+ auditLogInfo
}: {
profileId: string;
alg: string;
jwk: JsonWebKey;
payload: TCreateAcmeAccountPayload;
+ auditLogInfo: AuditLogInfo;
}) => Promise<TAcmeResponse<TCreateAcmeAccountResponse>>;
deactivateAcmeAccount: ({
profileId,
@@ -113,11 +116,13 @@ export type TPkiAcmeServiceFactory = {
createAcmeOrder: ({
profileId,
accountId,
- payload
+ payload,
+ auditLogInfo
}: {
profileId: string;
accountId: string;
payload: TCreateAcmeOrderPayload;
+ auditLogInfo: AuditLogInfo;
}) => Promise<TAcmeResponse<TAcmeOrderResource>>;
getAcmeOrder: ({
profileId,
@@ -132,21 +137,25 @@ export type TPkiAcmeServiceFactory = {
profileId,
accountId,
orderId,
- payload
+ payload,
+ auditLogInfo
}: {
profileId: string;
accountId: string;
orderId: string;
payload: TFinalizeAcmeOrderPayload;
+ auditLogInfo: AuditLogInfo;
}) => Promise<TAcmeResponse<TAcmeOrderResource>>;
downloadAcmeCertificate: ({
profileId,
accountId,
- orderId
+ orderId,
+ auditLogInfo
}: {
profileId: string;
accountId: string;
orderId: string;
+ auditLogInfo: AuditLogInfo;
}) => Promise<TAcmeResponse<string>>;
listAcmeOrders: ({
profileId,
@@ -168,12 +177,14 @@ export type TPkiAcmeServiceFactory = {
profileId,
accountId,
authzId,
- challengeId
+ challengeId,
+ auditLogInfo
}: {
profileId: string;
accountId: string;
authzId: string;
challengeId: string;
+ auditLogInfo: AuditLogInfo;
}) => Promise<TAcmeResponse<TRespondToAcmeChallengeResponse>>;
};