feat(core): Read ephemeral license from environment and clean up ee flags (#5797)
* remove enterprise feature schema for license.cert * bump license sdk version * Update packages/cli/package.json Co-authored-by: Cornelius Suermann <cornelius@n8n.io> --------- Co-authored-by: Cornelius Suermann <cornelius@n8n.io>
This commit is contained in:
committed by
GitHub
parent
5f6183a031
commit
a81ca7c19c
@@ -5,6 +5,7 @@
|
||||
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
|
||||
/* eslint-disable @typescript-eslint/naming-convention */
|
||||
import { Router } from 'express';
|
||||
import type { Request } from 'express';
|
||||
import bodyParser from 'body-parser';
|
||||
import { v4 as uuid } from 'uuid';
|
||||
import config from '@/config';
|
||||
@@ -12,12 +13,26 @@ import * as Db from '@/Db';
|
||||
import type { Role } from '@db/entities/Role';
|
||||
import { hashPassword } from '@/UserManagement/UserManagementHelper';
|
||||
import { eventBus } from '@/eventbus/MessageEventBus/MessageEventBus';
|
||||
import Container from 'typedi';
|
||||
import { License } from '../License';
|
||||
|
||||
if (process.env.E2E_TESTS !== 'true') {
|
||||
console.error('E2E endpoints only allowed during E2E tests');
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
const enabledFeatures = {
|
||||
sharing: true, //default to true here instead of setting it in config/index.ts for e2e
|
||||
ldap: false,
|
||||
saml: false,
|
||||
logStreaming: false,
|
||||
advancedExecutionFilters: false,
|
||||
};
|
||||
|
||||
type Feature = keyof typeof enabledFeatures;
|
||||
|
||||
Container.get(License).isFeatureEnabled = (feature: Feature) => enabledFeatures[feature] ?? false;
|
||||
|
||||
const tablesToTruncate = [
|
||||
'auth_identity',
|
||||
'auth_provider_sync_history',
|
||||
@@ -78,7 +93,7 @@ const setupUserManagement = async () => {
|
||||
};
|
||||
|
||||
const resetLogStreaming = async () => {
|
||||
config.set('enterprise.features.logStreaming', false);
|
||||
enabledFeatures.logStreaming = false;
|
||||
for (const id in eventBus.destinations) {
|
||||
await eventBus.removeDestination(id);
|
||||
}
|
||||
@@ -127,7 +142,8 @@ e2eController.post('/db/setup-owner', bodyParser.json(), async (req, res) => {
|
||||
res.writeHead(204).end();
|
||||
});
|
||||
|
||||
e2eController.post('/enable-feature/:feature', async (req, res) => {
|
||||
config.set(`enterprise.features.${req.params.feature}`, true);
|
||||
e2eController.post('/enable-feature/:feature', async (req: Request<{ feature: Feature }>, res) => {
|
||||
const { feature } = req.params;
|
||||
enabledFeatures[feature] = true;
|
||||
res.writeHead(204).end();
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user