fix(core): Initialize License and LDAP in the correct order (#5673)

This commit is contained in:
कारतोफ्फेलस्क्रिप्ट™
2023-03-10 19:05:51 +01:00
committed by GitHub
parent 5c4343b828
commit 90afa5e55f
3 changed files with 29 additions and 26 deletions

View File

@@ -130,12 +130,16 @@ import * as WorkflowExecuteAdditionalData from '@/WorkflowExecuteAdditionalData'
import { toHttpNodeParameters } from '@/CurlConverterHelper';
import { eventBusRouter } from '@/eventbus/eventBusRoutes';
import { isLogStreamingEnabled } from '@/eventbus/MessageEventBus/MessageEventBusHelper';
import { getLicense } from '@/License';
import { licenseController } from './license/license.controller';
import { Push, setupPushServer, setupPushHandler } from '@/push';
import { setupAuthMiddlewares } from './middlewares';
import { initEvents } from './events';
import { getLdapLoginLabel, isLdapEnabled, isLdapLoginEnabled } from './Ldap/helpers';
import {
getLdapLoginLabel,
handleLdapInit,
isLdapEnabled,
isLdapLoginEnabled,
} from './Ldap/helpers';
import { AbstractServer } from './AbstractServer';
import { configureMetrics } from './metrics';
import { setupBasicAuth } from './middlewares/basicAuth';
@@ -357,20 +361,6 @@ class Server extends AbstractServer {
return this.frontendSettings;
}
async initLicense(): Promise<void> {
const license = getLicense();
await license.init(this.frontendSettings.instanceId);
const activationKey = config.getEnv('license.activationKey');
if (activationKey) {
try {
await license.activate(activationKey);
} catch (e) {
LoggerProxy.error('Could not activate license', e);
}
}
}
private registerControllers(ignoredEndpoints: Readonly<string[]>) {
const { app, externalHooks, activeWorkflowRunner, nodeTypes } = this;
const repositories = Db.collections;
@@ -428,7 +418,6 @@ class Server extends AbstractServer {
await this.externalHooks.run('frontend.settings', [this.frontendSettings]);
await this.initLicense();
await this.postHog.init(this.frontendSettings.instanceId);
const publicApiEndpoint = config.getEnv('publicApi.path');
@@ -490,9 +479,8 @@ class Server extends AbstractServer {
}),
);
// ----------------------------------------
// User Management
// ----------------------------------------
await handleLdapInit();
this.registerControllers(ignoredEndpoints);
this.app.use(`/${this.restEndpoint}/credentials`, credentialsController);