Add frontend audit log ui for pki alerting / collection

This commit is contained in:
Tuan Dang
2024-08-09 09:28:15 -07:00
parent 705b4f7513
commit e1b9965f01
7 changed files with 192 additions and 2 deletions

View File

@@ -148,7 +148,6 @@ export enum EventType {
GET_PKI_ALERT = "get-pki-alert",
UPDATE_PKI_ALERT = "update-pki-alert",
DELETE_PKI_ALERT = "delete-pki-alert",
// new
CREATE_PKI_COLLECTION = "create-pki-collection",
GET_PKI_COLLECTION = "get-pki-collection",
UPDATE_PKI_COLLECTION = "update-pki-collection",
@@ -156,7 +155,6 @@ 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",
// end
CREATE_KMS = "create-kms",
UPDATE_KMS = "update-kms",
DELETE_KMS = "delete-kms",

View File

@@ -57,6 +57,17 @@ export const eventToNameMap: { [K in EventType]: string } = {
[EventType.DELETE_CERT]: "Delete certificate",
[EventType.REVOKE_CERT]: "Revoke certificate",
[EventType.GET_CERT_BODY]: "Get certificate body",
[EventType.CREATE_PKI_ALERT]: "Create PKI alert",
[EventType.GET_PKI_ALERT]: "Get PKI alert",
[EventType.UPDATE_PKI_ALERT]: "Update PKI alert",
[EventType.DELETE_PKI_ALERT]: "Delete PKI alert",
[EventType.CREATE_PKI_COLLECTION]: "Create PKI collection",
[EventType.GET_PKI_COLLECTION]: "Get PKI collection",
[EventType.UPDATE_PKI_COLLECTION]: "Update PKI collection",
[EventType.DELETE_PKI_COLLECTION]: "Delete PKI collection",
[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"
};

View File

@@ -71,5 +71,16 @@ export enum EventType {
DELETE_CERT = "delete-cert",
REVOKE_CERT = "revoke-cert",
GET_CERT_BODY = "get-cert-body",
CREATE_PKI_ALERT = "create-pki-alert",
GET_PKI_ALERT = "get-pki-alert",
UPDATE_PKI_ALERT = "update-pki-alert",
DELETE_PKI_ALERT = "delete-pki-alert",
CREATE_PKI_COLLECTION = "create-pki-collection",
GET_PKI_COLLECTION = "get-pki-collection",
UPDATE_PKI_COLLECTION = "update-pki-collection",
DELETE_PKI_COLLECTION = "delete-pki-collection",
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"
}

View File

@@ -1,5 +1,6 @@
import { CaStatus } from "../ca";
import { IdentityTrustedIp } from "../identities/types";
import { PkiItemType } from "../pkiCollections/constants";
import { ActorType, EventType, UserAgentType } from "./enums";
interface UserActorMetadata {
@@ -579,6 +580,95 @@ interface GetCertBody {
};
}
interface CreatePkiAlert {
type: EventType.CREATE_PKI_ALERT;
metadata: {
pkiAlertId: string;
pkiCollectionId: string;
name: string;
alertBeforeDays: number;
recipientEmails: string;
};
}
interface GetPkiAlert {
type: EventType.GET_PKI_ALERT;
metadata: {
pkiAlertId: string;
};
}
interface UpdatePkiAlert {
type: EventType.UPDATE_PKI_ALERT;
metadata: {
pkiAlertId: string;
pkiCollectionId?: string;
name?: string;
alertBeforeDays?: number;
recipientEmails?: string;
};
}
interface DeletePkiAlert {
type: EventType.DELETE_PKI_ALERT;
metadata: {
pkiAlertId: string;
};
}
interface CreatePkiCollection {
type: EventType.CREATE_PKI_COLLECTION;
metadata: {
pkiCollectionId: string;
name: string;
};
}
interface GetPkiCollection {
type: EventType.GET_PKI_COLLECTION;
metadata: {
pkiCollectionId: string;
};
}
interface UpdatePkiCollection {
type: EventType.UPDATE_PKI_COLLECTION;
metadata: {
pkiCollectionId: string;
name?: string;
};
}
interface DeletePkiCollection {
type: EventType.DELETE_PKI_COLLECTION;
metadata: {
pkiCollectionId: string;
};
}
interface GetPkiCollectionItems {
type: EventType.GET_PKI_COLLECTION_ITEMS;
metadata: {
pkiCollectionId: string;
};
}
interface AddPkiCollectionItem {
type: EventType.ADD_PKI_COLLECTION_ITEM;
metadata: {
pkiCollectionItemId: string;
pkiCollectionId: string;
type: PkiItemType;
itemId: string;
};
}
interface DeletePkiCollectionItem {
type: EventType.DELETE_PKI_COLLECTION_ITEM;
metadata: {
pkiCollectionItemId: string;
pkiCollectionId: string;
};
}
interface OrgAdminAccessProjectEvent {
type: EventType.ORG_ADMIN_ACCESS_PROJECT;
metadata: {
@@ -646,6 +736,17 @@ export type Event =
| DeleteCert
| RevokeCert
| GetCertBody
| CreatePkiAlert
| GetPkiAlert
| UpdatePkiAlert
| DeletePkiAlert
| CreatePkiCollection
| GetPkiCollection
| UpdatePkiCollection
| DeletePkiCollection
| GetPkiCollectionItems
| AddPkiCollectionItem
| DeletePkiCollectionItem
| OrgAdminAccessProjectEvent;
export type AuditLog = {

View File

@@ -323,6 +323,65 @@ export const LogsTableRow = ({ auditLog }: Props) => {
<p>{`Email: ${event.metadata.email}`}</p>
</Td>
);
case EventType.CREATE_PKI_ALERT:
case EventType.UPDATE_PKI_ALERT:
return (
<Td>
<p>{`Alert ID: ${event.metadata.pkiAlertId}`}</p>
<p>{`Name: ${event.metadata.name}`}</p>
<p>{`Alert Before Days: ${event.metadata.alertBeforeDays}`}</p>
</Td>
);
case EventType.GET_PKI_ALERT:
case EventType.DELETE_PKI_ALERT:
return (
<Td>
<p>{`Alert ID: ${event.metadata.pkiAlertId}`}</p>
</Td>
);
case EventType.CREATE_PKI_COLLECTION:
return (
<Td>
<p>{`Collection ID: ${event.metadata.pkiCollectionId}`}</p>
<p>{`Name: ${event.metadata.name}`}</p>
</Td>
);
case EventType.UPDATE_PKI_COLLECTION:
return (
<Td>
<p>{`Collection ID: ${event.metadata.pkiCollectionId}`}</p>
<p>{`Name: ${event.metadata.name}`}</p>
</Td>
);
case EventType.GET_PKI_COLLECTION:
case EventType.DELETE_PKI_COLLECTION:
return (
<Td>
<p>{`Collection ID: ${event.metadata.pkiCollectionId}`}</p>
</Td>
);
case EventType.GET_PKI_COLLECTION_ITEMS:
return (
<Td>
<p>{`Collection ID: ${event.metadata.pkiCollectionId}`}</p>
</Td>
);
case EventType.ADD_PKI_COLLECTION_ITEM:
return (
<Td>
<p>{`Collection ID: ${event.metadata.pkiCollectionId}`}</p>
<p>{`Collection Item ID: ${event.metadata.pkiCollectionItemId}`}</p>
<p>{`Type: ${event.metadata.type}`}</p>
<p>{`Item ID: ${event.metadata.itemId}`}</p>
</Td>
);
case EventType.DELETE_PKI_COLLECTION_ITEM:
return (
<Td>
<p>{`Collection ID: ${event.metadata.pkiCollectionId}`}</p>
<p>{`Collection Item ID: ${event.metadata.pkiCollectionItemId}`}</p>
</Td>
);
case EventType.CREATE_CA:
case EventType.GET_CA:
case EventType.UPDATE_CA:

View File

@@ -51,6 +51,8 @@ export const formSchema = z.object({
"ip-allowlist": generalPermissionSchema,
"certificate-authorities": generalPermissionSchema,
certificates: generalPermissionSchema,
"pki-alerts": generalPermissionSchema,
"pki-collections": generalPermissionSchema,
// akhilmhdh: refactor all keys like below
[ProjectPermissionSub.SecretApproval]: generalPermissionSchema,
workspace: z

View File

@@ -81,6 +81,14 @@ const SINGLE_PERMISSION_LIST = [
title: "Certificates",
formName: "certificates"
},
{
title: "PKI Collections",
formName: "pki-collections"
},
{
title: "PKI Alerts",
formName: "pki-alerts"
},
{
title: "Secret Rollback",
formName: "secret-rollback"