feat(Slack Trigger Node): Add support for signature verification (#17838)

This commit is contained in:
Jon
2025-08-01 17:32:01 +01:00
committed by GitHub
parent aced4bf86f
commit 133058183e
5 changed files with 252 additions and 4 deletions

View File

@@ -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();