Skip to content

Commit

Permalink
Merge pull request #134 from gaonkar18y/error-codes-fixes
Browse files Browse the repository at this point in the history
for306 Set correct error code
  • Loading branch information
keyurkarnik authored Aug 30, 2019
2 parents 6d9da19 + b5cc811 commit b659222
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 b659222

Please sign in to comment.