More audit logs

This commit is contained in:
Fang-Pen Lin
2025-12-09 16:51:16 -08:00
parent 2a80cdc659
commit 8598b276f6
2 changed files with 48 additions and 4 deletions

View File

@@ -50,6 +50,7 @@ import { WorkflowIntegration } from "@app/services/workflow-integration/workflow
import { KmipPermission } from "../kmip/kmip-enum";
import { ApprovalStatus } from "../secret-approval-request/secret-approval-request-types";
import { AcmeIdentifierType } from "../pki-acme/pki-acme-schemas";
export type TListProjectAuditLogDTO = {
filter: {
@@ -79,7 +80,8 @@ export type TCreateAuditLogDTO = {
| PlatformActor
| UnknownUserActor
| KmipClientActor
| AcmeProfileActor;
| AcmeProfileActor
| AcmeAccountActor;
orgId?: string;
projectId?: string;
} & BaseAuthData;
@@ -579,7 +581,8 @@ export enum EventType {
// PKI ACME
CREATE_ACME_ACCOUNT = "create-acme-account",
RETRIEVE_ACME_ACCOUNT = "retrieve-acme-account"
RETRIEVE_ACME_ACCOUNT = "retrieve-acme-account",
CREATE_ACME_ORDER = "create-acme-order"
}
export const filterableSecretEvents: EventType[] = [
@@ -624,6 +627,11 @@ interface AcmeProfileActorMetadata {
profileId: string;
}
interface AcmeAccountActorMetadata {
profileId: string;
accountId: string;
}
interface UnknownUserActorMetadata {}
export interface UserActor {
@@ -666,6 +674,11 @@ export interface AcmeProfileActor {
metadata: AcmeProfileActorMetadata;
}
export interface AcmeAccountActor {
type: ActorType.ACME_ACCOUNT;
metadata: AcmeAccountActorMetadata;
}
export type Actor =
| UserActor
| ServiceActor
@@ -4406,6 +4419,17 @@ interface RetrieveAcmeAccountEvent {
};
}
interface CreateAcmeOrderEvent {
type: EventType.CREATE_ACME_ORDER;
metadata: {
orderId: string;
identifiers: Array<{
type: AcmeIdentifierType;
value: string;
}>;
};
}
export type Event =
| CreateSubOrganizationEvent
| UpdateSubOrganizationEvent
@@ -4808,4 +4832,5 @@ export type Event =
| ApprovalRequestGrantGetEvent
| ApprovalRequestGrantRevokeEvent
| CreateAcmeAccountEvent
| RetrieveAcmeAccountEvent;
| RetrieveAcmeAccountEvent
| CreateAcmeOrderEvent;

View File

@@ -685,7 +685,26 @@ export const pkiAcmeServiceFactory = ({
})),
tx
);
// TODO: create audit log here
await auditLogService.createAuditLog({
projectId: account.profileId,
actor: {
type: ActorType.ACME_ACCOUNT,
metadata: {
profileId: account.profileId,
accountId: account.id
}
},
event: {
type: EventType.CREATE_ACME_ORDER,
metadata: {
orderId: createdOrder.id,
identifiers: authorizations.map((auth) => ({
type: auth.identifierType as AcmeIdentifierType,
value: auth.identifierValue
}))
}
}
});
return { ...createdOrder, authorizations, account };
});