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
misc: added audit logs for certificate template
Sheen Capadnganed0463e3e4a0
diff --git a/backend/src/ee/services/audit-log/audit-log-types.ts b/backend/src/ee/services/audit-log/audit-log-types.tsindex 41186756a1..37fb137d96 100644--- a/backend/src/ee/services/audit-log/audit-log-types.ts+++ b/backend/src/ee/services/audit-log/audit-log-types.ts@@ -162,7 +162,11 @@ export enum EventType {UPDATE_PROJECT_KMS = "update-project-kms",GET_PROJECT_KMS_BACKUP = "get-project-kms-backup",LOAD_PROJECT_KMS_BACKUP = "load-project-kms-backup",- ORG_ADMIN_ACCESS_PROJECT = "org-admin-accessed-project"+ ORG_ADMIN_ACCESS_PROJECT = "org-admin-accessed-project",+ CREATE_CERTIFICATE_TEMPLATE = "create-certificate-template",+ UPDATE_CERTIFICATE_TEMPLATE = "update-certificate-template",+ DELETE_CERTIFICATE_TEMPLATE = "delete-certificate-template",+ GET_CERTIFICATE_TEMPLATE = "get-certificate-template"}interface UserActorMetadata {@@ -1365,6 +1369,34 @@ interface LoadProjectKmsBackupEvent {metadata: Record<string, string>; // no metadata yet}+interface CreateCertificateTemplate {+ type: EventType.CREATE_CERTIFICATE_TEMPLATE;+ metadata: {+ certificateTemplateId: string;+ };+}++interface GetCertificateTemplate {+ type: EventType.GET_CERTIFICATE_TEMPLATE;+ metadata: {+ certificateTemplateId: string;+ };+}++interface UpdateCertificateTemplate {+ type: EventType.UPDATE_CERTIFICATE_TEMPLATE;+ metadata: {+ certificateTemplateId: string;+ };+}++interface DeleteCertificateTemplate {+ type: EventType.DELETE_CERTIFICATE_TEMPLATE;+ metadata: {+ certificateTemplateId: string;+ };+}+interface OrgAdminAccessProjectEvent {type: EventType.ORG_ADMIN_ACCESS_PROJECT;metadata: {@@ -1498,4 +1530,8 @@ export type Event =| UpdateProjectKmsEvent| GetProjectKmsBackupEvent| LoadProjectKmsBackupEvent- | OrgAdminAccessProjectEvent;+ | OrgAdminAccessProjectEvent+ | CreateCertificateTemplate+ | UpdateCertificateTemplate+ | GetCertificateTemplate+ | DeleteCertificateTemplate;diff --git a/backend/src/server/routes/v1/certificate-template-router.ts b/backend/src/server/routes/v1/certificate-template-router.tsindex 8a3bdd5232..5ca65044bf 100644--- a/backend/src/server/routes/v1/certificate-template-router.ts+++ b/backend/src/server/routes/v1/certificate-template-router.ts@@ -2,6 +2,7 @@ import ms from "ms";import { z } from "zod";import { CertificateTemplatesSchema } from "@app/db/schemas";+import { EventType } from "@app/ee/services/audit-log/audit-log-types";import { readLimit, writeLimit } from "@app/server/config/rateLimiter";import { verifyAuth } from "@app/server/plugins/auth/verify-auth";import { AuthMode } from "@app/services/auth/auth-type";@@ -49,6 +50,17 @@ export const registerCertificateTemplateRouter = async (server: FastifyZodProvidactorOrgId: req.permission.orgId});+ await server.services.auditLog.createAuditLog({+ ...req.auditLogInfo,+ projectId: certificateTemplate.projectId,+ event: {+ type: EventType.GET_CERTIFICATE_TEMPLATE,+ metadata: {+ certificateTemplateId: certificateTemplate.id+ }+ }+ });+return { certificateTemplate };}});@@ -84,6 +96,17 @@ export const registerCertificateTemplateRouter = async (server: FastifyZodProvid...req.body});+ await server.services.auditLog.createAuditLog({+ ...req.auditLogInfo,+ projectId: certificateTemplate.projectId,+ event: {+ type: EventType.CREATE_CERTIFICATE_TEMPLATE,+ metadata: {+ certificateTemplateId: certificateTemplate.id+ }+ }+ });+return { certificateTemplate };}});@@ -126,6 +149,17 @@ export const registerCertificateTemplateRouter = async (server: FastifyZodProvidactorOrgId: req.permission.orgId});+ await server.services.auditLog.createAuditLog({+ ...req.auditLogInfo,+ projectId: certificateTemplate.projectId,+ event: {+ type: EventType.UPDATE_CERTIFICATE_TEMPLATE,+ metadata: {+ certificateTemplateId: certificateTemplate.id+ }+ }+ });+return { certificateTemplate };}});@@ -156,6 +190,17 @@ export const registerCertificateTemplateRouter = async (server: FastifyZodProvidactorOrgId: req.permission.orgId});+ await server.services.auditLog.createAuditLog({+ ...req.auditLogInfo,+ projectId: certificateTemplate.projectId,+ event: {+ type: EventType.DELETE_CERTIFICATE_TEMPLATE,+ metadata: {+ certificateTemplateId: certificateTemplate.id+ }+ }+ });+return { certificateTemplate };}});diff --git a/backend/src/services/certificate-template/certificate-template-service.ts b/backend/src/services/certificate-template/certificate-template-service.tsindex 212fa05e48..459c988d8b 100644--- a/backend/src/services/certificate-template/certificate-template-service.ts+++ b/backend/src/services/certificate-template/certificate-template-service.ts@@ -66,7 +66,7 @@ export const certificateTemplateServiceFactory = ({ttl});- return certificateTemplate;+ return { ...certificateTemplate, projectId: ca.projectId };};const updateCertTemplate = async ({@@ -120,7 +120,7 @@ export const certificateTemplateServiceFactory = ({ttl});- return updatedCertTemplate;+ return { ...updatedCertTemplate, projectId: certTemplate.projectId };};const deleteCertTemplate = async ({ id, actorId, actorAuthMethod, actor, actorOrgId }: TDeleteCertTemplateDTO) => {@@ -146,7 +146,7 @@ export const certificateTemplateServiceFactory = ({const deletedCertTemplate = await certificateTemplateDAL.deleteById(certTemplate.id);- return deletedCertTemplate;+ return { ...deletedCertTemplate, projectId: certTemplate.projectId };};const getCertTemplate = async ({ id, actorId, actorAuthMethod, actor, actorOrgId }: TGetCertTemplateDTO) => {diff --git a/frontend/src/hooks/api/auditLogs/constants.tsx b/frontend/src/hooks/api/auditLogs/constants.tsxindex 8aadda2d8f..210061f7c3 100644--- a/frontend/src/hooks/api/auditLogs/constants.tsx+++ b/frontend/src/hooks/api/auditLogs/constants.tsx@@ -68,7 +68,11 @@ export const eventToNameMap: { [K in EventType]: string } = {[EventType.GET_PKI_COLLECTION_ITEMS]: "Get PKI collection items",[EventType.ADD_PKI_COLLECTION_ITEM]: "Add PKI collection item",[EventType.DELETE_PKI_COLLECTION_ITEM]: "Delete PKI collection item",- [EventType.ORG_ADMIN_ACCESS_PROJECT]: "Org admin accessed project"+ [EventType.ORG_ADMIN_ACCESS_PROJECT]: "Org admin accessed project",+ [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"};export const userAgentTTypeoNameMap: { [K in UserAgentType]: string } = {diff --git a/frontend/src/hooks/api/auditLogs/enums.tsx b/frontend/src/hooks/api/auditLogs/enums.tsxindex a6a2ada93a..80c0ce4313 100644--- a/frontend/src/hooks/api/auditLogs/enums.tsx+++ b/frontend/src/hooks/api/auditLogs/enums.tsx@@ -82,5 +82,9 @@ export enum EventType {GET_PKI_COLLECTION_ITEMS = "get-pki-collection-items",ADD_PKI_COLLECTION_ITEM = "add-pki-collection-item",DELETE_PKI_COLLECTION_ITEM = "delete-pki-collection-item",- ORG_ADMIN_ACCESS_PROJECT = "org-admin-accessed-project"+ ORG_ADMIN_ACCESS_PROJECT = "org-admin-accessed-project",+ CREATE_CERTIFICATE_TEMPLATE = "create-certificate-template",+ UPDATE_CERTIFICATE_TEMPLATE = "update-certificate-template",+ DELETE_CERTIFICATE_TEMPLATE = "delete-certificate-template",+ GET_CERTIFICATE_TEMPLATE = "get-certificate-template"}diff --git a/frontend/src/hooks/api/auditLogs/types.tsx b/frontend/src/hooks/api/auditLogs/types.tsxindex 0a34186f6a..ddc0e887ef 100644--- a/frontend/src/hooks/api/auditLogs/types.tsx+++ b/frontend/src/hooks/api/auditLogs/types.tsx@@ -679,6 +679,34 @@ interface OrgAdminAccessProjectEvent {}; // no metadata yet}+interface CreateCertificateTemplate {+ type: EventType.CREATE_CERTIFICATE_TEMPLATE;+ metadata: {+ certificateTemplateId: string;+ };+}++interface GetCertificateTemplate {+ type: EventType.GET_CERTIFICATE_TEMPLATE;+ metadata: {+ certificateTemplateId: string;+ };+}++interface UpdateCertificateTemplate {+ type: EventType.UPDATE_CERTIFICATE_TEMPLATE;+ metadata: {+ certificateTemplateId: string;+ };+}++interface DeleteCertificateTemplate {+ type: EventType.DELETE_CERTIFICATE_TEMPLATE;+ metadata: {+ certificateTemplateId: string;+ };+}+export type Event =| GetSecretsEvent| GetSecretEvent@@ -747,7 +775,11 @@ export type Event =| GetPkiCollectionItems| AddPkiCollectionItem| DeletePkiCollectionItem- | OrgAdminAccessProjectEvent;+ | OrgAdminAccessProjectEvent+ | CreateCertificateTemplate+ | UpdateCertificateTemplate+ | GetCertificateTemplate+ | DeleteCertificateTemplate;export type AuditLog = {id: string;diff --git a/frontend/src/views/Project/AuditLogsPage/components/LogsTableRow.tsx b/frontend/src/views/Project/AuditLogsPage/components/LogsTableRow.tsxindex f5e54ab475..ed25abe793 100644--- a/frontend/src/views/Project/AuditLogsPage/components/LogsTableRow.tsx+++ b/frontend/src/views/Project/AuditLogsPage/components/LogsTableRow.tsx@@ -406,6 +406,15 @@ export const LogsTableRow = ({ auditLog }: Props) => {<p>{`Cert CN: ${event.metadata.cn}`}</p></Td>);+ case EventType.CREATE_CERTIFICATE_TEMPLATE:+ case EventType.UPDATE_CERTIFICATE_TEMPLATE:+ case EventType.GET_CERTIFICATE_TEMPLATE:+ case EventType.DELETE_CERTIFICATE_TEMPLATE:+ return (+ <Td>+ <p>{`Certificate Template ID: ${event.metadata.certificateTemplateId}`}</p>+ </Td>+ );default:return <Td />;}