Skip to content

Instantly share code, notes, and snippets.

@wktk
Last active March 12, 2020 05:31
Show Gist options
  • Save wktk/c5e26d2028a3243e2271397330cc39f4 to your computer and use it in GitHub Desktop.
Save wktk/c5e26d2028a3243e2271397330cc39f4 to your computer and use it in GitHub Desktop.
Verify Slack signature with Node.js (on Lambda)
const crypto = require('crypto');
const verifySlackSignature = (event) => {
const rawString = `v0:${event.headers['X-Slack-Request-Timestamp']}:${event.body}`;
const hmac = crypto.createHmac('sha256', process.env['SLACK_SIGNING_SECRET']);
return `v0=${hmac.update(rawString).digest('hex')}` === event.headers['X-Slack-Signature'];
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment