Skip to content

Commit

Permalink
152640618 Correctly pass apikey to next plugin
Browse files Browse the repository at this point in the history
Remove the check of 'sendErr' when the token is valid because 'sendErr' should come in picture for failure cases
Set the header 'x-api-key' on req object and pass the control to next plugin
  • Loading branch information
gaonkar18y authored and keyurkarnik committed Jan 21, 2021
1 parent 1d409d1 commit 2dd55d5
Showing 1 changed file with 2 additions and 8 deletions.
10 changes: 2 additions & 8 deletions extauth/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,10 +124,7 @@ module.exports.init = function(config, logger, stats) {
if (!keepAuthHeader) {
delete(req.headers['authorization']);
}
if (!sendErr) {
//if this plugin is not sending errors, assume MG is not in local mode
req.headers['x-api-key'] = jwtdecode.payloadObj[client_id];
}
req.headers['x-api-key'] = jwtdecode.payloadObj[client_id];
} else {
debug("ERROR - JWT is invalid");
delete(req.headers['authorization']);
Expand Down Expand Up @@ -162,10 +159,7 @@ module.exports.init = function(config, logger, stats) {
if (!keepAuthHeader) {
delete(req.headers['authorization']);
}
if (!sendErr) {
//if this plugin is not sending errors, assume MG is not in local mode
req.headers['x-api-key'] = jwtdecode.payloadObj[client_id];
}
req.headers['x-api-key'] = jwtdecode.payloadObj[client_id];
} else {
debug("ERROR - JWT is invalid");
delete(req.headers['authorization']);
Expand Down

0 comments on commit 2dd55d5

Please sign in to comment.