(core) Add audit logging machinery

Summary:
Adds machinery to support audit logging in the backend.

Logging is currently implemented by streaming events to external HTTP
endpoints. All flavors of Grist support a default "grist" payload format,
and Grist Enterprise additionally supports an HEC-compatible payload format.

Logging of all audit events will be added at a later date.

Test Plan: Server tests.

Reviewers: paulfitz

Reviewed By: paulfitz

Differential Revision: https://phab.getgrist.com/D4331
This commit is contained in:
George Gevoian
2024-09-09 16:04:21 -04:00
parent 14718120bd
commit 3e22b89fa2
20 changed files with 466 additions and 14 deletions

31
app/common/AuditEvent.ts Normal file
View File

@@ -0,0 +1,31 @@
export interface AuditEvent<Name extends AuditEventName> {
event: {
/** The event name. */
name: Name;
/** The user that triggered the event. */
user: AuditEventUser | null;
/** Additional event details. */
details: AuditEventDetails[Name] | null;
};
/** ISO 8601 timestamp of when the event was logged. */
timestamp: string;
}
export type AuditEventName =
| 'createDocument';
export interface AuditEventUser {
/** The user's id. */
id: number | null;
/** The user's email address. */
email: string | null;
/** The user's name. */
name: string | null;
}
export interface AuditEventDetails {
createDocument: {
/** The ID of the document. */
id: string;
};
}