(core) Add installation/site configuration endpoints

Summary:
A new set of endpoints for managing installation and site configuration have been added:
 - GET `/api/install/configs/:key` - get the value of the configuration item with the specified key
 - PUT `/api/install/configs/:key` - set the value of the configuration item with the specified key
     - body: the JSON value of the configuration item
 - DELETE `/api/install/configs/:key` - delete the configuration item with the specified key
 - GET `/api/orgs/:oid/configs/:key` - get the value of the configuration item with the specified key
 - PUT `/api/orgs/:oid/configs/:key` - set the value of the configuration item with the specified key
     - body: the JSON value of the configuration item
 - DELETE `/api/orgs/:oid/configs/:key` - delete the configuration item with the specified key

Configuration consists of key/value pairs, where keys are strings (e.g. `"audit_logs_streaming_destinations"`) and values are JSON, including literals like numbers and strings. Only installation admins and site owners are permitted to modify installation and site configuration, respectively.

The endpoints are planned to be used in an upcoming feature for enabling audit log streaming for an installation and/or site. Future functionality may use the endpoints as well, which may require extending the current capabilities (e.g. adding support for storing secrets, additional metadata fields, etc.).

Test Plan: Server tests

Reviewers: paulfitz, jarek

Reviewed By: paulfitz, jarek

Subscribers: jarek

Differential Revision: https://phab.getgrist.com/D4377
This commit is contained in:
George Gevoian
2024-10-15 20:45:10 -04:00
parent 89468bd9f0
commit ecff88bd32
12 changed files with 1477 additions and 126 deletions

26
app/common/Config-ti.ts Normal file
View File

@@ -0,0 +1,26 @@
/**
* This module was automatically generated by `ts-interface-builder`
*/
import * as t from "ts-interface-checker";
// tslint:disable:object-literal-key-quotes
export const ConfigKey = t.lit("audit_log_streaming_destinations");
export const ConfigValue = t.name("AuditLogStreamingDestinations");
export const AuditLogStreamingDestinations = t.array("AuditLogStreamingDestination");
export const AuditLogStreamingDestination = t.iface([], {
"id": "string",
"name": t.lit("splunk"),
"url": "string",
"token": t.opt("string"),
});
const exportedTypeSuite: t.ITypeSuite = {
ConfigKey,
ConfigValue,
AuditLogStreamingDestinations,
AuditLogStreamingDestination,
};
export default exportedTypeSuite;

25
app/common/Config.ts Normal file
View File

@@ -0,0 +1,25 @@
import ConfigsTI from "app/common/Config-ti";
import { CheckerT, createCheckers } from "ts-interface-checker";
export type ConfigKey = "audit_log_streaming_destinations";
export type ConfigValue = AuditLogStreamingDestinations;
export type AuditLogStreamingDestinations = AuditLogStreamingDestination[];
export interface AuditLogStreamingDestination {
id: string;
name: "splunk";
url: string;
token?: string;
}
export const ConfigKeyChecker = createCheckers(ConfigsTI)
.ConfigKey as CheckerT<ConfigKey>;
const { AuditLogStreamingDestinations } = createCheckers(ConfigsTI);
export const ConfigValueCheckers = {
audit_log_streaming_destinations:
AuditLogStreamingDestinations as CheckerT<AuditLogStreamingDestinations>,
};