Add option to ignore requests from bots

This commit is contained in:
pemontto
2021-12-09 13:28:14 +00:00
parent 6453996de3
commit 3128cbf874
3 changed files with 28 additions and 0 deletions

View File

@@ -21,6 +21,7 @@ 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) {
@@ -627,6 +628,13 @@ export class Wait implements INodeType {
placeholder: 'webhook',
description: 'This suffix path will be appended to the restart URL. Helpful when using multiple wait nodes. Note: Does not support expressions.',
},
{
displayName: 'Ignore Bots',
name: 'ignoreBots',
type: 'boolean',
default: false,
description: 'Set to true to ignore requests from bots like link previewers and web crawlers',
},
// {
// displayName: 'Raw Body',
// name: 'rawBody',
@@ -656,6 +664,11 @@ export class Wait 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 (incomingAuthentication === 'basicAuth') {
// Basic authorization is needed to call webhook
const httpBasicAuth = await this.getCredentials('httpBasicAuth');