Make it possible to open endpoints

This commit is contained in:
Jan Oberhauser 2020-09-23 14:14:31 +02:00
parent 395fe69bd3
commit 3374fda7c6
2 changed files with 13 additions and 2 deletions

View file

@ -300,6 +300,12 @@ const config = convict({
},
security: {
excludeEndpoints: {
doc: 'Additional endpoints to exclude auth checks. Multiple endpoints can be separated by colon (":")',
format: String,
default: '',
env: 'N8N_AUTH_EXCLUDE_ENDPOINTS'
},
basicAuth: {
active: {
format: 'Boolean',

View file

@ -172,8 +172,13 @@ class App {
async config(): Promise<void> {
this.versions = await GenericHelpers.getVersions();
const ignoredEndpoints = _(['healthz', this.endpointWebhook, this.endpointWebhookTest, this.endpointPresetCredentials]).compact().join('|');
const authIgnoreRegex = new RegExp(`^\/(${ignoredEndpoints})\/?.*$`);
const excludeEndpoints = config.get('security.excludeEndpoints') as string;
const ignoredEndpoints = ['healthz', this.endpointWebhook, this.endpointWebhookTest, this.endpointPresetCredentials];
ignoredEndpoints.push.apply(ignoredEndpoints, excludeEndpoints.split(':'));
const authIgnoreRegex = new RegExp(`^\/(${_(ignoredEndpoints).compact().join('|')})\/?.*$`);
// Check for basic auth credentials if activated
const basicAuthActive = config.get('security.basicAuth.active') as boolean;