diff --git a/apikeys/index.js b/apikeys/index.js index 59ec4f8..aefc3a5 100644 --- a/apikeys/index.js +++ b/apikeys/index.js @@ -136,7 +136,7 @@ module.exports.init = function(config, logger, stats) { } if (response.statusCode !== 200) { if (config.allowInvalidAuthorization) { - console.warn("ignoring err"); + logger.consoleLog('warn', "ignoring err"); // TODO: convert to logger.eventLog return next(); } else { debug("verify apikey access_denied"); @@ -164,7 +164,7 @@ module.exports.init = function(config, logger, stats) { } if (!isValid) { if (config.allowInvalidAuthorization) { - console.warn("ignoring err"); + logger.consoleLog('warn', "ignoring err"); // TODO: convert to logger.eventLog return next(); } else { debug("invalid token"); diff --git a/eurekaclient/index.js b/eurekaclient/index.js index fc53cfd..2febbcd 100644 --- a/eurekaclient/index.js +++ b/eurekaclient/index.js @@ -11,7 +11,7 @@ var os = require('os'); const port = process.env.PORT || 8000; const Eureka = require('eureka-js-client').Eureka; -module.exports.init = function (config /*, logger, stats */) { +module.exports.init = function (config , logger, /* stats */) { //const lookup = config.servicemap; @@ -28,7 +28,7 @@ module.exports.init = function (config /*, logger, stats */) { try { client.start(); } catch (err) { - console.error(err); + logger.consoleLog('error', err); // TODO: convert to logger.eventLog client.stop(); } @@ -87,7 +87,7 @@ module.exports.init = function (config /*, logger, stats */) { req.targetSecure = false; } } else { - console.warn("Target endpoint from Eureka not found"); + logger.consoleLog('warn', "Target endpoint from Eureka not found"); // TODO: convert to logger.eventLog } next(); } diff --git a/extauth/index.js b/extauth/index.js index c8e5d6a..7e01963 100644 --- a/extauth/index.js +++ b/extauth/index.js @@ -41,7 +41,7 @@ module.exports.init = function(config, logger, stats) { }, function(err, response, body) { if (err) { debug('publickey gateway timeout'); - console.log(err); + logger.consoleLog('log', err); // TODO: convert to logger.eventLog } else { debug("loaded public keys"); if (keyType === 'jwk') { diff --git a/lib/basicAuth.js b/lib/basicAuth.js index 1d05ab7..05cf5ec 100644 --- a/lib/basicAuth.js +++ b/lib/basicAuth.js @@ -226,14 +226,16 @@ class BasicAuthorizerPlugin { isValid = JWS.verifyJWT(oauthtoken, this.config.public_key, this.acceptField); } } catch (error) { - console.warn('error parsing jwt: ' + oauthtoken); + // TODO: convert to logger.eventLog + this.logger.consoleLog('warn', 'error parsing jwt: ' + oauthtoken); } return(isValid) } tryValidationBipass(req, res) { if ( this.allowInvalidAuthorization ) { - console.warn('ignoring err in verify no valid JWT'); + // TODO: convert to logger.eventLog + this.logger.consoleLog('warn', 'ignoring err in verify no valid JWT'); return this.next(); } else { return this.invalidToken(req, res); @@ -286,7 +288,8 @@ class BasicAuthorizerPlugin { decodedToken = JWS.parse(oauthtoken); } catch (err) { if ( this.allowInvalidAuthorization ) { - console.warn('ignoring err'); + // TODO: convert to logger.eventLog + this.logger.consoleLog('warn', 'ignoring err'); return next(); } else { return this.invalidToken(req, res); @@ -496,20 +499,23 @@ class BasicAuthorizerPlugin { try { res.setHeader('content-type', 'application/json'); } catch (e) { - console.warn("oath response object lacks setHeader") + // TODO: convert to logger.eventLog + logger.consoleLog('warn', "oath response object lacks setHeader"); } } try { res.end(JSON.stringify(response)); } catch (e) { - console.warn("oath response object is not supplied by runtime") + // TODO: convert to logger.eventLog + logger.consoleLog('warn', "oath response object is not supplied by runtime"); } try { stats.incrementStatusCount(res.statusCode); } catch (e) { - console.warn("oath stats object is not supplied by runtime") + // TODO: convert to logger.eventLog + logger.consoleLog('warn',"oath stats object is not supplied by runtime"); } next(code, message); diff --git a/oauth/index.js b/oauth/index.js index 71af423..96c489a 100644 --- a/oauth/index.js +++ b/oauth/index.js @@ -237,12 +237,12 @@ module.exports.init = function(config, logger, stats) { isValid = JWS.verifyJWT(oauthtoken, config.public_key, acceptField); } } catch (error) { - console.warn('error parsing jwt: ' + oauthtoken); + logger.consoleLog('warn', 'error parsing jwt: ' + oauthtoken); } } if (!isValid) { if (config.allowInvalidAuthorization) { - console.warn('ignoring err'); + logger.consoleLog('warn', 'ignoring err') return next(); } else { debug('invalid token'); @@ -272,11 +272,11 @@ module.exports.init = function(config, logger, stats) { isValid = JWS.verifyJWT(oauthtoken, config.public_key, acceptField); } } catch (error) { - console.warn('error parsing jwt: ' + oauthtoken); + logger.consoleLog('warn', 'error parsing jwt: ' + oauthtoken); } if (!isValid) { if (config.allowInvalidAuthorization) { - console.warn('ignoring err'); + logger.consoleLog('warn', 'ignoring err'); return next(); } else { debug('invalid token'); @@ -493,20 +493,23 @@ function sendError(req, res, next, logger, stats, code, message) { try { res.setHeader('content-type', 'application/json'); } catch (e) { - console.warn("oath response object lacks setHeader") + // TODO: convert to logger.eventLog + logger.consoleLog('warn', "oath response object lacks setHeader"); } } try { res.end(JSON.stringify(response)); } catch (e) { - console.warn("oath response object is not supplied by runtime") + // TODO: convert to logger.eventLog + logger.consoleLog('warn', "oath response object is not supplied by runtime"); } try { stats.incrementStatusCount(res.statusCode); } catch (e) { - console.warn("oath stats object is not supplied by runtime") + // TODO: convert to logger.eventLog + logger.consoleLog('warn', "oath stats object is not supplied by runtime"); } next(code, message); diff --git a/oauthv2/index.js b/oauthv2/index.js index 5c52089..d33382b 100644 --- a/oauthv2/index.js +++ b/oauthv2/index.js @@ -89,7 +89,7 @@ module.exports.init = function(config, logger, stats) { decodedToken = JWS.parse(oauthtoken); } catch (err) { if (config.allowInvalidAuthorization) { - console.warn('ignoring err'); + logger.consoleLog('warn', 'ignoring err'); return next(); } else { debug('invalid token'); @@ -119,12 +119,12 @@ module.exports.init = function(config, logger, stats) { isValid = JWS.verifyJWT(oauthtoken, config.public_key, acceptField); } } catch (error) { - console.warn('error parsing jwt: ' + oauthtoken); + logger.consoleLog('warn', 'error parsing jwt: ' + oauthtoken); } } if (!isValid) { if (config.allowInvalidAuthorization) { - console.warn('ignoring err'); + logger.consoleLog('warn', 'ignoring err'); return next(); } else { debug('invalid token'); @@ -154,11 +154,13 @@ module.exports.init = function(config, logger, stats) { isValid = JWS.verifyJWT(oauthtoken, config.public_key, acceptField); } } catch (error) { - console.warn('error parsing jwt: ' + oauthtoken); + // TODO: convert to logger.eventLog + logger.consoleLog('warn', 'error parsing jwt: ' + oauthtoken); } if (!isValid) { if (config.allowInvalidAuthorization) { - console.warn('ignoring err'); + // TODO: convert to logger.eventLog + logger.consoleLog('warn', 'ignoring err'); return next(); } else { debug('invalid token');