-
-
Save engina/6257ef29edc2b5480dcbe71b1716be52 to your computer and use it in GitHub Desktop.
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
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