Moves core create object and core getLoginSystem to server/lib (#994)

This enables code in ext/ to be able to access it (e.g for proxying / interception).

Additionally adds getCreate() to enable future refactoring of `const create` away from being a global singleton constant.
pull/1001/head
Spoffy 4 months ago committed by GitHub
parent 5dc4706dc7
commit e56b416c7a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -0,0 +1,22 @@
import { checkMinIOBucket, checkMinIOExternalStorage,
configureMinIOExternalStorage } from 'app/server/lib/configureMinIOExternalStorage';
import { makeSimpleCreator } from 'app/server/lib/ICreate';
import { Telemetry } from 'app/server/lib/Telemetry';
export const makeCoreCreator = () => makeSimpleCreator({
deploymentType: 'core',
// This can and should be overridden by GRIST_SESSION_SECRET
// (or generated randomly per install, like grist-omnibus does).
sessionSecret: 'Phoo2ag1jaiz6Moo2Iese2xoaphahbai3oNg7diemohlah0ohtae9iengafieS2Hae7quungoCi9iaPh',
storage: [
{
name: 'minio',
check: () => checkMinIOExternalStorage() !== undefined,
checkBackend: () => checkMinIOBucket(),
create: configureMinIOExternalStorage,
},
],
telemetry: {
create: (dbManager, gristServer) => new Telemetry(dbManager, gristServer),
}
});

@ -0,0 +1,12 @@
import { getForwardAuthLoginSystem } from 'app/server/lib/ForwardAuthLogin';
import { GristLoginSystem } from 'app/server/lib/GristServer';
import { getMinimalLoginSystem } from 'app/server/lib/MinimalLogin';
import { getOIDCLoginSystem } from 'app/server/lib/OIDCConfig';
import { getSamlLoginSystem } from 'app/server/lib/SamlConfig';
export async function getCoreLoginSystem(): Promise<GristLoginSystem> {
return await getSamlLoginSystem() ||
await getOIDCLoginSystem() ||
await getForwardAuthLoginSystem() ||
await getMinimalLoginSystem();
}

@ -1,22 +1,13 @@
import { checkMinIOBucket, checkMinIOExternalStorage, import {ICreate} from "app/server/lib/ICreate";
configureMinIOExternalStorage } from 'app/server/lib/configureMinIOExternalStorage'; import {makeCoreCreator} from "app/server/lib/coreCreator";
import { makeSimpleCreator } from 'app/server/lib/ICreate';
import { Telemetry } from 'app/server/lib/Telemetry';
export const create = makeSimpleCreator({ export const create: ICreate = makeCoreCreator();
deploymentType: 'core',
// This can and should be overridden by GRIST_SESSION_SECRET /**
// (or generated randomly per install, like grist-omnibus does). * Fetch the ICreate object for grist-core.
sessionSecret: 'Phoo2ag1jaiz6Moo2Iese2xoaphahbai3oNg7diemohlah0ohtae9iengafieS2Hae7quungoCi9iaPh', * Placeholder to enable eventual refactoring away from a global singleton constant.
storage: [ * Needs to exist in all repositories before core can be switched!
{ */
name: 'minio', export function getCreator(): ICreate {
check: () => checkMinIOExternalStorage() !== undefined, return create;
checkBackend: () => checkMinIOBucket(), }
create: configureMinIOExternalStorage,
},
],
telemetry: {
create: (dbManager, gristServer) => new Telemetry(dbManager, gristServer),
}
});

@ -1,12 +1,6 @@
import { getForwardAuthLoginSystem } from 'app/server/lib/ForwardAuthLogin'; import { getCoreLoginSystem } from "app/server/lib/coreLogins";
import { GristLoginSystem } from 'app/server/lib/GristServer'; import { GristLoginSystem } from "app/server/lib/GristServer";
import { getMinimalLoginSystem } from 'app/server/lib/MinimalLogin';
import { getOIDCLoginSystem } from 'app/server/lib/OIDCConfig';
import { getSamlLoginSystem } from 'app/server/lib/SamlConfig';
export async function getLoginSystem(): Promise<GristLoginSystem> { export async function getLoginSystem(): Promise<GristLoginSystem> {
return await getSamlLoginSystem() || return getCoreLoginSystem();
await getOIDCLoginSystem() ||
await getForwardAuthLoginSystem() ||
await getMinimalLoginSystem();
} }

Loading…
Cancel
Save