mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 01:56:46 +00:00
🔀 Merge branch 'ignore-bots' of https://github.com/pemontto/n8n into pemontto-ignore-bots
This commit is contained in:
@@ -20,6 +20,8 @@ import * as fs from 'fs';
|
||||
|
||||
import * as formidable from 'formidable';
|
||||
|
||||
import * as isbot from 'isbot';
|
||||
|
||||
function authorizationError(resp: Response, realm: string, responseCode: number, message?: string) {
|
||||
if (message === undefined) {
|
||||
message = 'Authorization problem!';
|
||||
@@ -378,6 +380,13 @@ export class Webhook implements INodeType {
|
||||
default: false,
|
||||
description: 'Raw body (binary)',
|
||||
},
|
||||
{
|
||||
displayName: 'Ignore Bots',
|
||||
name: 'ignoreBots',
|
||||
type: 'boolean',
|
||||
default: false,
|
||||
description: 'Set to true to ignore requests from bots like link previewers and web crawlers',
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
@@ -391,6 +400,11 @@ export class Webhook implements INodeType {
|
||||
const headers = this.getHeaderData();
|
||||
const realm = 'Webhook';
|
||||
|
||||
const ignoreBots = options.ignoreBots as boolean;
|
||||
if (ignoreBots && isbot((headers as IDataObject)['user-agent'] as string)) {
|
||||
return authorizationError(resp, realm, 403);
|
||||
}
|
||||
|
||||
if (authentication === 'basicAuth') {
|
||||
// Basic authorization is needed to call webhook
|
||||
const httpBasicAuth = await this.getCredentials('httpBasicAuth');
|
||||
|
||||
Reference in New Issue
Block a user