feat(core): Add license support to n8n (#4566)

* add sdk

* add license manager

* type fix

* add basic func

* store to db

* update default

* activate license

* add sharing flag

* fix setup

* clear license

* update conosle log to info

* refactor

* use npm dependency

* update error logs

* add simple test

* add license tests

* update tests

* update pnpm package

* fix error handling types

* Update packages/cli/src/config/schema.ts

Co-authored-by: Cornelius Suermann <cornelius@n8n.io>

* make feature enum

* add warning

* update sdk

* Update packages/cli/src/config/schema.ts

Co-authored-by: Cornelius Suermann <cornelius@n8n.io>

Co-authored-by: Cornelius Suermann <cornelius@n8n.io>
This commit is contained in:
Mutasem Aldmour
2022-11-21 15:41:24 +01:00
committed by GitHub
parent a9bdc0bbfe
commit 30e5d3d04c
9 changed files with 328 additions and 2 deletions

View File

@@ -160,6 +160,7 @@ import * as WorkflowExecuteAdditionalData from '@/WorkflowExecuteAdditionalData'
import { ResponseError } from '@/ResponseHelper';
import { toHttpNodeParameters } from '@/CurlConverterHelper';
import { setupErrorMiddleware } from '@/ErrorReporting';
import { getLicense } from '@/License';
require('body-parser-xml')(bodyParser);
@@ -384,6 +385,16 @@ class App {
return this.frontendSettings;
}
async initLicense(): Promise<void> {
const license = getLicense();
await license.init(this.frontendSettings.instanceId, this.frontendSettings.versionCli);
const activationKey = config.getEnv('license.activationKey');
if (activationKey) {
await license.activate(activationKey);
}
}
async config(): Promise<void> {
const enableMetrics = config.getEnv('endpoints.metrics.enable');
let register: Registry;
@@ -406,6 +417,8 @@ class App {
await this.externalHooks.run('frontend.settings', [this.frontendSettings]);
await this.initLicense();
const excludeEndpoints = config.getEnv('security.excludeEndpoints');
const ignoredEndpoints = [