mirror of
https://github.com/gristlabs/grist-core.git
synced 2024-10-27 20:44:07 +00:00
3e22b89fa2
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
31 lines
958 B
TypeScript
31 lines
958 B
TypeScript
import {appSettings} from 'app/server/lib/AppSettings';
|
|
import {GristAuditLogger} from 'app/server/lib/GristAuditLogger';
|
|
|
|
export function configureGristAuditLogger() {
|
|
const options = checkGristAuditLogger();
|
|
if (!options) { return undefined; }
|
|
|
|
return new GristAuditLogger(options);
|
|
}
|
|
|
|
export function checkGristAuditLogger() {
|
|
const settings = appSettings.section('auditLogger').section('http');
|
|
const endpoint = settings.flag('endpoint').readString({
|
|
envVar: 'GRIST_AUDIT_HTTP_ENDPOINT',
|
|
});
|
|
if (!endpoint) { return undefined; }
|
|
|
|
const payloadFormat = settings.flag('payloadFormat').readString({
|
|
envVar: 'GRIST_AUDIT_HTTP_PAYLOAD_FORMAT',
|
|
defaultValue: 'grist',
|
|
});
|
|
if (payloadFormat !== 'grist') { return undefined; }
|
|
|
|
const authorizationHeader = settings.flag('authorizationHeader').readString({
|
|
envVar: 'GRIST_AUDIT_HTTP_AUTHORIZATION_HEADER',
|
|
censor: true,
|
|
});
|
|
|
|
return {endpoint, authorizationHeader};
|
|
}
|