diff --git a/configAccessMatch.js b/configAccessMatch.js index 51c2339..ee77c92 100644 --- a/configAccessMatch.js +++ b/configAccessMatch.js @@ -12,11 +12,12 @@ configAccessMatch.users = [ // Activity related with request which the following headers configAccessMatch.headers = [ - { "Fiware-service": "smartcity" }, + { "fiware-service": "smartcity" }, + { "x-real-ip": "127.0.0.1" } ]; // Activity related with request including the following subpaths -configAccessMatch.subpath = [ +configAccessMatch.subpaths = [ '/v1', ]; diff --git a/lib/middleware/proxy.js b/lib/middleware/proxy.js index 65f3d85..0786c7f 100644 --- a/lib/middleware/proxy.js +++ b/lib/middleware/proxy.js @@ -222,7 +222,32 @@ function accountInfo(req, res, next) { // CHeck here MATCH file patterns: if (req.userName in configAccessMatch.users ) { - accessMsg += ' MATCHED USER'; + accessMsg += ' MATCHED USER'; + } + for (var header of configAccessMatch.headers) { + if ('fiware-service' in Object.keys(header)) { + if (req.service.includes(header['fiware-service'])) { + accessMsg += ' MATCHED HEADER Service'; + } + } else if ('fiware-servicepath' in Object.keys(header)) { + if (req.subService.includes(header['fiware-servicepath'])) { + accessMsg += ' MATCHED HEADER SubService'; + } + } else if ('x-real-ip' in Object.keys(header)) { + if (req.connection.remoteAddress.includes(header['x-real-ip'])) { + accessMsg += ' MATCHED HEADER Origin'; + } + } + } + for (var subpath of configAccessMatch.subpaths) { + if (req.path.includes(subpath)) { + accessMsg += ' MATCHED SUBPATH ' + subpath; + } + } + for (var text of configAccessMatch.body) { + if (JSON.stringify(req.body).includes(text)) { + accessMsg += ' MATCHED BODY ' + text; + } } accessLogger.info(accessMsg + @@ -237,7 +262,7 @@ function accountInfo(req, res, next) { ' | SubService=' + req.subService + ' | Action=' + req.action + ' | Path=' + req.path + - ' | Body=' + JSON.stringify(req.body).slice(0, 100) + + ' | Body=' + JSON.stringify(req.body).slice(0, 100) + // not all body ' | Date=' + new Date().toJSON()); }); }