Skip to content

Commit

Permalink
Set correct error code
Browse files Browse the repository at this point in the history
Fix the issue introduced in 3.0.5 due to incorrect error code being set.
  • Loading branch information
gaonkar18y committed Aug 16, 2019
1 parent 11cfe65 commit b5cc811
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
12 changes: 6 additions & 6 deletions extauth/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ module.exports.init = function(config, logger, stats) {
delete(req.headers['authorization']);
delete(req.headers['x-api-key']);
if (sendErr) {
return sendError(req, res, next, logger, stats, 'access_denied', 'missing_authorization');
return sendError(req, res, next, logger, stats, 'missing_authorization', 'missing_authorization');
}
} else {
var jwtdecode = JWS.parse(jwtpayload[1]);
Expand All @@ -133,15 +133,15 @@ module.exports.init = function(config, logger, stats) {
delete(req.headers['authorization']);
delete(req.headers['x-api-key']);
if (sendErr) {
return sendError(req, res, next, logger, stats, 'access_denied','invalid_token');
return sendError(req, res, next, logger, stats, 'invalid_token','invalid_token');
}
}
} else if (!kid && keyType === 'jwk') {
debug("ERROR - JWT Missing kid in header");
delete(req.headers['authorization']);
delete(req.headers['x-api-key']);
if (sendErr) {
return sendError(req, res, next, logger, stats, 'access_denied','invalid_token');
return sendError(req, res, next, logger, stats, 'invalid_token','invalid_token');
}
} else {
var jwk = getJWK(kid);
Expand All @@ -150,7 +150,7 @@ module.exports.init = function(config, logger, stats) {
delete(req.headers['authorization']);
delete(req.headers['x-api-key']);
if (sendErr) {
return sendError(req, res, next, logger, stats, 'access_denied','invalid_authorization');
return sendError(req, res, next, logger, stats, 'invalid_authorization','invalid_authorization');
}
} else {
debug("Found JWK");
Expand Down Expand Up @@ -181,7 +181,7 @@ module.exports.init = function(config, logger, stats) {
delete(req.headers['authorization']);
delete(req.headers['x-api-key']);
if (sendErr) {
return sendError(req, res, next, logger, stats,'access_denied', 'missing_authorization');
return sendError(req, res, next, logger, stats,'missing_authorization', 'missing_authorization');
}
}
}
Expand All @@ -190,7 +190,7 @@ module.exports.init = function(config, logger, stats) {
delete(req.headers['authorization']);
delete(req.headers['x-api-key']);
if (sendErr) {
return sendError(req, res, next, logger, stats,'access_denied', 'invalid_authorization');
return sendError(req, res, next, logger, stats,'invalid_authorization', 'invalid_authorization');
}
}
next();
Expand Down
6 changes: 3 additions & 3 deletions oauthv2/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ module.exports.init = function(config, logger, stats) {
return next();
} else {
debug('invalid token');
return sendError(req, res, next, logger, stats, 'access_denied', 'invalid_token');
return sendError(req, res, next, logger, stats, 'invalid_token', 'invalid_token');
}
}

Expand Down Expand Up @@ -130,7 +130,7 @@ module.exports.init = function(config, logger, stats) {
return next();
} else {
debug('invalid token');
return sendError(req, res, next, logger, stats,'access_denied', 'invalid_token');
return sendError(req, res, next, logger, stats,'invalid_token', 'invalid_token');
}
} else {
if (tokenvalue === null || tokenvalue === undefined) {
Expand Down Expand Up @@ -164,7 +164,7 @@ module.exports.init = function(config, logger, stats) {
return next();
} else {
debug('invalid token');
return sendError(req, res, next, logger, stats, 'access_denied', 'invalid_token');
return sendError(req, res, next, logger, stats, 'invalid_token', 'invalid_token');
}
} else {
authorize(req, res, next, logger, stats, decodedToken.payloadObj);
Expand Down

0 comments on commit b5cc811

Please sign in to comment.