Expose public api activation to the settings

This commit is contained in:
ricardo 2022-04-28 12:06:22 -04:00
parent 20087373b9
commit f762e143c3
4 changed files with 13 additions and 6 deletions

View file

@ -576,11 +576,11 @@ export const schema = {
},
},
publicApiEndpoints: {
disable: {
publicApi: {
disabled: {
format: Boolean,
default: false,
env: 'N8N_PUBLIC_API_DISABLE',
env: 'N8N_PUBLIC_API_DISABLED',
doc: 'Whether to disable the Public API',
},
path: {

View file

@ -457,6 +457,7 @@ export interface IN8nUISettings {
personalizationSurveyEnabled: boolean;
defaultLocale: string;
userManagement: IUserManagementSettings;
publicApi: IPublicApiSettings;
workflowTagsDisabled: boolean;
logLevel: 'info' | 'debug' | 'warn' | 'error' | 'verbose' | 'silent';
hiringBannerEnabled: boolean;
@ -480,6 +481,9 @@ export interface IUserManagementSettings {
showSetupOnFirstLoad?: boolean;
smtpSetup: boolean;
}
export interface IPublicApiSettings {
enabled: boolean;
}
export interface IPackageVersions {
cli: string;

View file

@ -253,7 +253,7 @@ class App {
this.payloadSizeMax = config.get('endpoints.payloadSizeMax');
this.timezone = config.get('generic.timezone');
this.restEndpoint = config.get('endpoints.rest');
this.publicApiEndpoint = config.get('publicApiEndpoints.path');
this.publicApiEndpoint = config.get('publicApi.path');
this.activeWorkflowRunner = ActiveWorkflowRunner.getInstance();
this.testWebhooks = TestWebhooks.getInstance();
@ -324,6 +324,9 @@ class App {
config.getEnv('userManagement.skipInstanceOwnerSetup') === false,
smtpSetup: isEmailSetUp(),
},
publicApi: {
enabled: config.getEnv('publicApi.disabled') === false,
},
workflowTagsDisabled: config.getEnv('workflowTagsDisabled'),
logLevel: config.getEnv('logs.level'),
hiringBannerEnabled: config.getEnv('hiringBanner.enabled'),
@ -581,7 +584,7 @@ class App {
return ResponseHelper.sendSuccessResponse(res, {}, true, 204);
});
if (!config.getEnv('publicApiEndpoints.disable')) {
if (!config.getEnv('publicApi.disabled')) {
this.app.use(`/${this.publicApiEndpoint}`, ...(await loadPublicApiVersions()));
}
// Parse cookies for easier access

View file

@ -2,7 +2,7 @@ import config from '../../../config';
export const REST_PATH_SEGMENT = config.getEnv('endpoints.rest') as Readonly<string>;
export const PUBLIC_API_REST_PATH_SEGMENT = config.get('publicApiEndpoints.path') as Readonly<string>;
export const PUBLIC_API_REST_PATH_SEGMENT = config.getEnv('publicApi.path') as Readonly<string>;
export const AUTHLESS_ENDPOINTS: Readonly<string[]> = [
'healthz',