Last active
March 12, 2020 05:31
-
-
Save wktk/c5e26d2028a3243e2271397330cc39f4 to your computer and use it in GitHub Desktop.
Verify Slack signature with Node.js (on Lambda)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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