Skip to content

Instantly share code, notes, and snippets.

@simonr-cb
Created January 12, 2018 16:36
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 simonr-cb/069f5a5477b782a15dab779a25a162d8 to your computer and use it in GitHub Desktop.
Save simonr-cb/069f5a5477b782a15dab779a25a162d8 to your computer and use it in GitHub Desktop.
// Verify and decode the Approov token and respond with 403 if the JWT
// could not be decoded, has expired, or has an invalid signature
const checkApproovTokenJWT = jwt({
secret: new Buffer(config.approovTokenSecret, 'base64'),
getToken: function fromApproovTokenHeader(req) {
// Retrieve the Approov token used to authenticate the mobile app from the request header
var approovToken = req.get('Approov-Token')
if (!approovToken) {
console.log('\tApproov token not specified or in the wrong format')
}
return approovToken
},
algorithms: ['HS256']
})
router.use(checkApproovTokenJWT)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment