Skip to content

Commit

Permalink
(core) Make improvements to audit logging
Browse files Browse the repository at this point in the history
Summary:
 - Environment variables for configuring streaming have been replaced
   with the value of `audit_log_streaming_destinations` key, from the `configs`
   table.
     - The previous `hec` payload format has been replaced with a streaming
       destination with name `splunk`.
     - The previous `grist` payload format has been replaced with a streaming
       destination with name `other`.
 - Event streaming may now be configured on a per-site basis:
     - Events that specify a context with the site id are automatically streamed
       to that site's streaming destinations.
     - Events are still streamed to an installation's streaming destinations
       unconditionally.
 - Multiple streaming destinations may now be configured for an installation or site.
 - General improvements to the overall shape of audit events.
 - General improvements to the output of audit event documentation, including a new
   sample section with example JSON output of each events' details.

Test Plan: Server tests

Reviewers: paulfitz

Reviewed By: paulfitz

Subscribers: paulfitz

Differential Revision: https://phab.getgrist.com/D4383
  • Loading branch information
georgegevoian committed Nov 1, 2024
1 parent 99b6fd1 commit f063488
Show file tree
Hide file tree
Showing 42 changed files with 3,410 additions and 1,817 deletions.
603 changes: 0 additions & 603 deletions app/common/AuditEvent.ts

This file was deleted.

22 changes: 21 additions & 1 deletion app/common/Config-ti.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,21 @@
import * as t from "ts-interface-checker";
// tslint:disable:object-literal-key-quotes

export const Config = t.iface([], {
"id": "string",
"key": "ConfigKey",
"value": "ConfigValue",
"createdAt": "string",
"updatedAt": "string",
"org": t.opt("ConfigOrg"),
});

export const ConfigOrg = t.iface([], {
"id": "number",
"name": "string",
"domain": t.union("string", "null"),
});

export const ConfigKey = t.lit("audit_log_streaming_destinations");

export const ConfigValue = t.name("AuditLogStreamingDestinations");
Expand All @@ -12,15 +27,20 @@ export const AuditLogStreamingDestinations = t.array("AuditLogStreamingDestinati

export const AuditLogStreamingDestination = t.iface([], {
"id": "string",
"name": t.lit("splunk"),
"name": "AuditLogStreamingDestinationName",
"url": "string",
"token": t.opt("string"),
});

export const AuditLogStreamingDestinationName = t.union(t.lit("splunk"), t.lit("other"));

const exportedTypeSuite: t.ITypeSuite = {
Config,
ConfigOrg,
ConfigKey,
ConfigValue,
AuditLogStreamingDestinations,
AuditLogStreamingDestination,
AuditLogStreamingDestinationName,
};
export default exportedTypeSuite;
19 changes: 18 additions & 1 deletion app/common/Config.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,21 @@
import ConfigsTI from "app/common/Config-ti";
import { CheckerT, createCheckers } from "ts-interface-checker";

export interface Config {
id: string;
key: ConfigKey;
value: ConfigValue;
createdAt: string;
updatedAt: string;
org?: ConfigOrg;
}

export interface ConfigOrg {
id: number;
name: string;
domain: string | null;
}

export type ConfigKey = "audit_log_streaming_destinations";

export type ConfigValue = AuditLogStreamingDestinations;
Expand All @@ -9,11 +24,13 @@ export type AuditLogStreamingDestinations = AuditLogStreamingDestination[];

export interface AuditLogStreamingDestination {
id: string;
name: "splunk";
name: AuditLogStreamingDestinationName;
url: string;
token?: string;
}

export type AuditLogStreamingDestinationName = "splunk" | "other";

export const ConfigKeyChecker = createCheckers(ConfigsTI)
.ConfigKey as CheckerT<ConfigKey>;

Expand Down
Loading

0 comments on commit f063488

Please sign in to comment.