Created
January 12, 2018 16:52
Star
You must be signed in to star a gist
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
// Just use the static secret during HMAC verification for this demo stage | |
hmac = crypto.createHmac('sha256', Buffer.from(secret, 'base64')) | |
... | |
... | |
// Compute the request HMAC using the HMAC SHA-256 algorithm | |
hmac.update(req.protocol) | |
hmac.update(req.host) | |
hmac.update(req.originalUrl) | |
hmac.update(req.get('Authorization')) | |
var ourShipFastHMAC = hmac.digest('hex') | |
// Check to see if our HMAC matches the one sent in the request header | |
// and send an error response if it doesn't | |
if (ourShipFastHMAC != requestShipFastHMAC) { | |
... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment