Skip to content

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

misc: added audit logs

Sheen Capadngan5b26928751ea
diff --git a/backend/src/ee/services/audit-log/audit-log-types.ts b/backend/src/ee/services/audit-log/audit-log-types.ts
index 0d07d005b8..52972d942f 100644
--- a/backend/src/ee/services/audit-log/audit-log-types.ts
+++ b/backend/src/ee/services/audit-log/audit-log-types.ts
@@ -166,7 +166,10 @@ export enum EventType {
CREATE_CERTIFICATE_TEMPLATE = "create-certificate-template",
UPDATE_CERTIFICATE_TEMPLATE = "update-certificate-template",
DELETE_CERTIFICATE_TEMPLATE = "delete-certificate-template",
- GET_CERTIFICATE_TEMPLATE = "get-certificate-template"
+ GET_CERTIFICATE_TEMPLATE = "get-certificate-template",
+ CREATE_CERTIFICATE_TEMPLATE_EST_CONFIG = "create-certificate-template-est-config",
+ UPDATE_CERTIFICATE_TEMPLATE_EST_CONFIG = "update-certificate-template-est-config",
+ GET_CERTIFICATE_TEMPLATE_EST_CONFIG = "get-certificate-template-est-config"
}
interface UserActorMetadata {
@@ -1420,6 +1423,29 @@ interface OrgAdminAccessProjectEvent {
}; // no metadata yet
}
+interface CreateCertificateTemplateEstConfig {
+ type: EventType.CREATE_CERTIFICATE_TEMPLATE_EST_CONFIG;
+ metadata: {
+ certificateTemplateId: string;
+ isEnabled: boolean;
+ };
+}
+
+interface UpdateCertificateTemplateEstConfig {
+ type: EventType.UPDATE_CERTIFICATE_TEMPLATE_EST_CONFIG;
+ metadata: {
+ certificateTemplateId: string;
+ isEnabled: boolean;
+ };
+}
+
+interface GetCertificateTemplateEstConfig {
+ type: EventType.GET_CERTIFICATE_TEMPLATE_EST_CONFIG;
+ metadata: {
+ certificateTemplateId: string;
+ };
+}
+
export type Event =
| GetSecretsEvent
| GetSecretEvent
@@ -1547,4 +1573,7 @@ export type Event =
| CreateCertificateTemplate
| UpdateCertificateTemplate
| GetCertificateTemplate
- | DeleteCertificateTemplate;
+ | DeleteCertificateTemplate
+ | CreateCertificateTemplateEstConfig
+ | UpdateCertificateTemplateEstConfig
+ | GetCertificateTemplateEstConfig;
diff --git a/backend/src/server/routes/v1/certificate-template-router.ts b/backend/src/server/routes/v1/certificate-template-router.ts
index 786f3bdaef..c9d2410fd5 100644
--- a/backend/src/server/routes/v1/certificate-template-router.ts
+++ b/backend/src/server/routes/v1/certificate-template-router.ts
@@ -241,6 +241,18 @@ export const registerCertificateTemplateRouter = async (server: FastifyZodProvid
...req.body
});
+ await server.services.auditLog.createAuditLog({
+ ...req.auditLogInfo,
+ projectId: estConfig.projectId,
+ event: {
+ type: EventType.CREATE_CERTIFICATE_TEMPLATE_EST_CONFIG,
+ metadata: {
+ certificateTemplateId: estConfig.certificateTemplateId,
+ isEnabled: estConfig.isEnabled as boolean
+ }
+ }
+ });
+
return estConfig;
}
});
@@ -276,6 +288,18 @@ export const registerCertificateTemplateRouter = async (server: FastifyZodProvid
...req.body
});
+ await server.services.auditLog.createAuditLog({
+ ...req.auditLogInfo,
+ projectId: estConfig.projectId,
+ event: {
+ type: EventType.UPDATE_CERTIFICATE_TEMPLATE_EST_CONFIG,
+ metadata: {
+ certificateTemplateId: estConfig.certificateTemplateId,
+ isEnabled: estConfig.isEnabled as boolean
+ }
+ }
+ });
+
return estConfig;
}
});
@@ -308,6 +332,17 @@ export const registerCertificateTemplateRouter = async (server: FastifyZodProvid
actorOrgId: req.permission.orgId
});
+ await server.services.auditLog.createAuditLog({
+ ...req.auditLogInfo,
+ projectId: estConfig.projectId,
+ event: {
+ type: EventType.GET_CERTIFICATE_TEMPLATE_EST_CONFIG,
+ metadata: {
+ certificateTemplateId: estConfig.certificateTemplateId
+ }
+ }
+ });
+
return estConfig;
}
});
diff --git a/backend/src/services/certificate-template/certificate-template-service.ts b/backend/src/services/certificate-template/certificate-template-service.ts
index f180340584..cb1caa39f9 100644
--- a/backend/src/services/certificate-template/certificate-template-service.ts
+++ b/backend/src/services/certificate-template/certificate-template-service.ts
@@ -257,7 +257,7 @@ export const certificateTemplateServiceFactory = ({
isEnabled
});
- return estConfig;
+ return { ...estConfig, projectId: certTemplate.projectId };
};
const updateEstConfiguration = async ({
@@ -331,7 +331,7 @@ export const certificateTemplateServiceFactory = ({
const estConfig = await certificateTemplateEstConfigDAL.updateById(originalCaEstConfig.id, updatedData);
- return estConfig;
+ return { ...estConfig, projectId: certTemplate.projectId };
};
const getEstConfiguration = async (dto: TGetEstConfigurationDTO) => {
@@ -388,7 +388,8 @@ export const certificateTemplateServiceFactory = ({
id: estConfig.id,
isEnabled: estConfig.isEnabled,
caChain: decryptedCaChain.toString(),
- hashedPassphrase: estConfig.hashedPassphrase
+ hashedPassphrase: estConfig.hashedPassphrase,
+ projectId: certTemplate.projectId
};
};
diff --git a/frontend/src/hooks/api/auditLogs/constants.tsx b/frontend/src/hooks/api/auditLogs/constants.tsx
index 210061f7c3..b9ba072649 100644
--- a/frontend/src/hooks/api/auditLogs/constants.tsx
+++ b/frontend/src/hooks/api/auditLogs/constants.tsx
@@ -72,7 +72,12 @@ export const eventToNameMap: { [K in EventType]: string } = {
[EventType.CREATE_CERTIFICATE_TEMPLATE]: "Create certificate template",
[EventType.UPDATE_CERTIFICATE_TEMPLATE]: "Update certificate template",
[EventType.DELETE_CERTIFICATE_TEMPLATE]: "Delete certificate template",
- [EventType.GET_CERTIFICATE_TEMPLATE]: "Get certificate template"
+ [EventType.GET_CERTIFICATE_TEMPLATE]: "Get certificate template",
+ [EventType.GET_CERTIFICATE_TEMPLATE_EST_CONFIG]: "Get certificate template EST configuration",
+ [EventType.CREATE_CERTIFICATE_TEMPLATE_EST_CONFIG]:
+ "Create certificate template EST configuration",
+ [EventType.UPDATE_CERTIFICATE_TEMPLATE_EST_CONFIG]:
+ "Update certificate template EST configuration"
};
export const userAgentTTypeoNameMap: { [K in UserAgentType]: string } = {
diff --git a/frontend/src/hooks/api/auditLogs/enums.tsx b/frontend/src/hooks/api/auditLogs/enums.tsx
index 80c0ce4313..6df32aa0ba 100644
--- a/frontend/src/hooks/api/auditLogs/enums.tsx
+++ b/frontend/src/hooks/api/auditLogs/enums.tsx
@@ -86,5 +86,8 @@ export enum EventType {
CREATE_CERTIFICATE_TEMPLATE = "create-certificate-template",
UPDATE_CERTIFICATE_TEMPLATE = "update-certificate-template",
DELETE_CERTIFICATE_TEMPLATE = "delete-certificate-template",
- GET_CERTIFICATE_TEMPLATE = "get-certificate-template"
+ GET_CERTIFICATE_TEMPLATE = "get-certificate-template",
+ CREATE_CERTIFICATE_TEMPLATE_EST_CONFIG = "create-certificate-template-est-config",
+ UPDATE_CERTIFICATE_TEMPLATE_EST_CONFIG = "update-certificate-template-est-config",
+ GET_CERTIFICATE_TEMPLATE_EST_CONFIG = "get-certificate-template-est-config"
}
diff --git a/frontend/src/hooks/api/auditLogs/types.tsx b/frontend/src/hooks/api/auditLogs/types.tsx
index d7825637d1..f9b53d0373 100644
--- a/frontend/src/hooks/api/auditLogs/types.tsx
+++ b/frontend/src/hooks/api/auditLogs/types.tsx
@@ -719,6 +719,29 @@ interface DeleteCertificateTemplate {
};
}
+interface CreateCertificateTemplateEstConfig {
+ type: EventType.CREATE_CERTIFICATE_TEMPLATE_EST_CONFIG;
+ metadata: {
+ certificateTemplateId: string;
+ isEnabled: boolean;
+ };
+}
+
+interface UpdateCertificateTemplateEstConfig {
+ type: EventType.UPDATE_CERTIFICATE_TEMPLATE_EST_CONFIG;
+ metadata: {
+ certificateTemplateId: string;
+ isEnabled: boolean;
+ };
+}
+
+interface GetCertificateTemplateEstConfig {
+ type: EventType.GET_CERTIFICATE_TEMPLATE_EST_CONFIG;
+ metadata: {
+ certificateTemplateId: string;
+ };
+}
+
export type Event =
| GetSecretsEvent
| GetSecretEvent
@@ -791,7 +814,10 @@ export type Event =
| CreateCertificateTemplate
| UpdateCertificateTemplate
| GetCertificateTemplate
- | DeleteCertificateTemplate;
+ | DeleteCertificateTemplate
+ | UpdateCertificateTemplateEstConfig
+ | CreateCertificateTemplateEstConfig
+ | GetCertificateTemplateEstConfig;
export type AuditLog = {
id: string;
diff --git a/frontend/src/views/Project/AuditLogsPage/components/LogsTableRow.tsx b/frontend/src/views/Project/AuditLogsPage/components/LogsTableRow.tsx
index ea0e687bb9..c1652aaba5 100644
--- a/frontend/src/views/Project/AuditLogsPage/components/LogsTableRow.tsx
+++ b/frontend/src/views/Project/AuditLogsPage/components/LogsTableRow.tsx
@@ -428,6 +428,20 @@ export const LogsTableRow = ({ auditLog }: Props) => {
<p>{`Certificate Template ID: ${event.metadata.certificateTemplateId}`}</p>
</Td>
);
+ case EventType.CREATE_CERTIFICATE_TEMPLATE_EST_CONFIG:
+ case EventType.UPDATE_CERTIFICATE_TEMPLATE_EST_CONFIG:
+ return (
+ <Td>
+ <p>{`Certificate Template ID: ${event.metadata.certificateTemplateId}`}</p>
+ <p>{`Enabled: ${event.metadata.isEnabled}`}</p>
+ </Td>
+ );
+ case EventType.GET_CERTIFICATE_TEMPLATE_EST_CONFIG:
+ return (
+ <Td>
+ <p>{`Certificate Template ID: ${event.metadata.certificateTemplateId}`}</p>
+ </Td>
+ );
default:
return <Td />;
}