Skip to content

Commit

Permalink
catch exception inside map.read
Browse files Browse the repository at this point in the history
  • Loading branch information
theganyo committed Jun 7, 2019
1 parent b8dadd5 commit 06aff8f
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions oauthv2/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,13 +109,17 @@ module.exports.init = function(config, logger, stats) {
}
} else {
debug('token not found in cache');
if (keys) {
debug('using jwk');
var pem = getPEM(decodedToken, keys);
isValid = JWS.verifyJWT(oauthtoken, pem, acceptField);
} else {
debug('validating jwt');
isValid = JWS.verifyJWT(oauthtoken, config.public_key, acceptField);
try {
if (keys) {
debug('using jwk');
var pem = getPEM(decodedToken, keys);
isValid = JWS.verifyJWT(oauthtoken, pem, acceptField);
} else {
debug('validating jwt');
isValid = JWS.verifyJWT(oauthtoken, config.public_key, acceptField);
}
} catch (error) {
console.warn('error parsing jwt: ' + oauthtoken);
}
}
if (!isValid) {
Expand Down

0 comments on commit 06aff8f

Please sign in to comment.