mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 10:02:05 +00:00
feat(Slack Trigger Node): Add support for signature verification (#17838)
This commit is contained in:
@@ -13,7 +13,7 @@ import {
|
||||
NodeConnectionTypes,
|
||||
} from 'n8n-workflow';
|
||||
|
||||
import { downloadFile, getChannelInfo, getUserInfo } from './SlackTriggerHelpers';
|
||||
import { downloadFile, getChannelInfo, getUserInfo, verifySignature } from './SlackTriggerHelpers';
|
||||
import { slackApiRequestAllItems } from './V2/GenericFunctions';
|
||||
|
||||
export class SlackTrigger implements INodeType {
|
||||
@@ -53,7 +53,7 @@ export class SlackTrigger implements INodeType {
|
||||
},
|
||||
{
|
||||
displayName:
|
||||
'Set up a webhook in your Slack app to enable this node. <a href="https://docs.n8n.io/integrations/builtin/trigger-nodes/n8n-nodes-base.slacktrigger/#configure-a-webhook-in-slack" target="_blank">More info</a>',
|
||||
'Set up a webhook in your Slack app to enable this node. <a href="https://docs.n8n.io/integrations/builtin/trigger-nodes/n8n-nodes-base.slacktrigger/#configure-a-webhook-in-slack" target="_blank">More info</a>. We also recommend setting up a <a href="https://docs.n8n.io/integrations/builtin/trigger-nodes/n8n-nodes-base.slacktrigger/#verify-the-webhook" target="_blank">signing secret</a> to ensure the authenticity of requests.',
|
||||
name: 'notice',
|
||||
type: 'notice',
|
||||
default: '',
|
||||
@@ -321,8 +321,17 @@ export class SlackTrigger implements INodeType {
|
||||
const binaryData: IBinaryKeyData = {};
|
||||
const watchWorkspace = this.getNodeParameter('watchWorkspace', false) as boolean;
|
||||
let eventChannel: string = '';
|
||||
// Check if the request is a challenge request
|
||||
|
||||
if (!(await verifySignature.call(this))) {
|
||||
const res = this.getResponseObject();
|
||||
res.status(401).send('Unauthorized').end();
|
||||
return {
|
||||
noWebhookResponse: true,
|
||||
};
|
||||
}
|
||||
|
||||
if (req.body.type === 'url_verification') {
|
||||
// Check if the request is a challenge request
|
||||
const res = this.getResponseObject();
|
||||
res.status(200).json({ challenge: req.body.challenge }).end();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user