Skip to content

Instantly share code, notes, and snippets.

@engina
Created July 4, 2016 12:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save engina/6257ef29edc2b5480dcbe71b1716be52 to your computer and use it in GitHub Desktop.
Save engina/6257ef29edc2b5480dcbe71b1716be52 to your computer and use it in GitHub Desktop.
app.use('/api/notification', function(req, res, next) {
req.hmac = crypto.createHmac('sha256', APP_SECRET);
req.on('data', function(chunk) {
req.hmac.update(chunk);
});
req.on('end', function() {
let signGiven = req.get('X-Dropbox-Signature');
let signComputed = req.hmac.digest('hex');
if(signGiven !== signComputed) {
log.warn('Dropbox Webhook Signature Fail');
res.sendStatus(403);
res.end();
} else {
log.info('Dropbox Webhook Signature verified');
}
});
next();
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment