{"_id":"@curaelabs/express-ipfilter","_rev":"1-ff41c2c48c3aa2a124c5ec789e5fbf24","name":"@curaelabs/express-ipfilter","dist-tags":{"latest":"0.0.1"},"versions":{"0.0.1":{"name":"@curaelabs/express-ipfilter","description":"A light-weight IP address based filtering system - based of of express-ipfilter but without the vulnerabilities.","version":"0.0.1","author":{"name":"Sylvain Girard"},"dependencies":{"ip":"^1.1.5","lodash":"^4.17.11","range_check":"^1.4.0"},"devDependencies":{"@babel/core":"^7.2.2","@babel/preset-env":"^7.2.3","grunt":"^1.0.3","grunt-babel":"^8.0.0","grunt-check-dependencies":"^1.0.0","grunt-cli":"^1.3.2","grunt-contrib-copy":"^1.0.0","grunt-contrib-watch":"^1.1.0","grunt-eslint":"^21.0.0","grunt-mocha-istanbul":"^5.0.2","grunt-mocha-test":"^0.13.3","istanbul":"^0.4.0","load-grunt-tasks":"^4.0.0","minimatch":"^3.0.4","mocha":"^5.2.0","mocha-junit-reporter":"^1.18.0"},"keywords":["middleware","ipfilter","ip filter","ipban","ip ban","express"],"repository":{"type":"git","url":"git+https://github.com/sylvaingirardbe/express-ipfilter.git"},"main":"index.js","scripts":{"test":"mocha -R spec"},"license":"MIT","gitHead":"e725609aa033212b7de95e8c894055dbaa212f32","bugs":{"url":"https://github.com/sylvaingirardbe/express-ipfilter/issues"},"homepage":"https://github.com/sylvaingirardbe/express-ipfilter#readme","_id":"@curaelabs/express-ipfilter@0.0.1","_npmVersion":"6.4.1","_nodeVersion":"10.11.0","_npmUser":{"name":"curaelabs","email":"sylvain@curaelabs.eu"},"dist":{"integrity":"sha512-49f8aJgQh1/MlGs0eWIXsTGZ4xVXtQM12F+7GwEIqxi3FgNhlcV+olK/Xe3Xkr7ktq17eUiqTcyTO+lWP0lRNg==","shasum":"f299c9a795d12d09a6a56eff24bf7703cbfd6be9","tarball":"https://registry.npmjs.org/@curaelabs/express-ipfilter/-/express-ipfilter-0.0.1.tgz","fileCount":28,"unpackedSize":119461,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJcP5X8CRA9TVsSAnZWagAAwEUP/AjlMJgvsJkQhOuchx8o\nOKcmIf8E75wNT4dWzxYDuZtrlzjTagbUCjwDq1HbAFGUpB39CwziivWWO+wE\nHg1kOM4llUFejsIdN1MYwIxiq7pENlfzgdl/JGhS+Cx1UsFnRV5PKrP6I+Q8\nsEAu9GmeS4WkrSHblqZEZdxhJkyCKuBptaCid/2p4yNqDOF7pNKBzVC47BJ/\nKGqeRwNhFIDa444LQ/r9F9x5gfRBzYKHmf3Lwk8goT9eulSf6EpjfCYVILSm\nVuS21ydxhNl/KPCqJJ+Vhtoqh+oYpmKiWlmaLQKCXan3tGP1rSHqc4FOY/Bs\nDHE5BB92fjpru3YTaW3jobC02zWp8OKb6XhLBKa2xpsBKU7+MejmaFbfcR+o\nsg9ZV1/wALRssJp8mTZpjbfVFdRCW3zTRSNulezAbXCs456Uzubsp493ly5C\n9U8VybKu1fXa7IWzvKoERmpuFjnSPzm2mo8lFlATiWmoIMMQYdTKU7ak95Ev\n+tHr7bRjQx+beiV248iCigd1BZRNbJkjZJ3FEvyEUvMNvmNZ70cEhSysn4ho\nBbfDKGXyHBuTn3AAvYdiWcoM/O3aovHtIBp61HAHmffGKBBHFy54dDbmfQ7S\nY2wwwyXW9mNThdpDzgbrMHQm0Sk87LJnXvROCvP+eYpMrADz9ZmlIcRuWaVe\nKkPb\r\n=GOqM\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCax9JGoTZfyUNzPgzKcwdDxSDEUtYG5r4YfveSF8T/ZQIgVEP5nFj0G1ME4Hu2ANwv1Q3XFZRz7/pj4YtIbbrYNcY="}]},"maintainers":[{"name":"curaelabs","email":"sylvain@curaelabs.eu"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/express-ipfilter_0.0.1_1547671036044_0.18634562969646362"},"_hasShrinkwrap":false}},"time":{"created":"2019-01-16T20:37:16.043Z","0.0.1":"2019-01-16T20:37:16.253Z","modified":"2022-04-05T02:12:38.421Z"},"maintainers":[{"name":"curaelabs","email":"sylvain@curaelabs.eu"}],"description":"A light-weight IP address based filtering system - based of of express-ipfilter but without the vulnerabilities.","homepage":"https://github.com/sylvaingirardbe/express-ipfilter#readme","keywords":["middleware","ipfilter","ip filter","ipban","ip ban","express"],"repository":{"type":"git","url":"git+https://github.com/sylvaingirardbe/express-ipfilter.git"},"author":{"name":"Sylvain Girard"},"bugs":{"url":"https://github.com/sylvaingirardbe/express-ipfilter/issues"},"license":"MIT","readme":"@curaelabs/express-ipfilter: A light-weight IP address based filtering system\r\n=================================================================================\r\n\r\nThis package provides easy IP based access control. This can be achieved either by blacklisting certain IPs and whitelisting all others, or whitelisting certain IPs and blacklisting all others.\r\n\r\n## Version\r\n0.0.1\r\n\r\n## Installation\r\n\r\nRecommended installation is with npm. To add node-ipfilter to your project, do:\r\n\r\n    npm install @curaelabs/express-ipfilter\r\n\r\n## Usage with Express\r\n\r\n> NOTE: Starting with version 0.1.0, allow forwarded IP addresses through headers (forward, Cloudflare, Codio) are disabled by **default**. You must explicitly enable them by adding them to the `allowedHeaders` list.\r\n\r\nBlacklisting certain IP addresses, while allowing all other IPs:\r\n\r\n```javascript\r\n// Init dependencies\r\nvar express = require('express'),\r\n    ipfilter = require('express-ipfilter').IpFilter;\r\n\r\n// Blacklist the following IPs\r\nvar ips = ['127.0.0.1'];\r\n\r\n// Create the server\r\napp.use(ipfilter(ips));\r\napp.listen(3000);\r\n```\r\n\r\nWhitelisting certain IP addresses, while denying all other IPs:\r\n\r\n```javascript\r\n// Init dependencies\r\n// Init dependencies\r\nvar express = require('express'),\r\n    ipfilter = require('express-ipfilter').IpFilter;\r\n\r\n// Whitelist the following IPs\r\nvar ips = ['127.0.0.1'];\r\n\r\n// Create the server\r\napp.use(ipfilter(ips, {mode: 'allow'}));\r\n\r\nmodule.exports = app;\r\n```\r\n\r\nUsing CIDR subnet masks for ranges:\r\n\r\n```javascript\r\nvar ips = ['127.0.0.1/24'];\r\n\r\n// Create the server\r\napp.use(ipfilter(ips, {mode: 'allow'}));\r\n\r\nmodule.exports = app;\r\n```\r\n\r\nUsing IP ranges:\r\n\r\n```javascript\r\nvar ips = [['127.0.0.1','127.0.0.10']];\r\n\r\n// Create the server\r\napp.use(ipfilter(ips, {mode: 'allow'}));\r\n\r\nmodule.exports = app;\r\n```\r\n\r\nUsing a function to get Ips:\r\n\r\n```javascript\r\nvar ips = function() { return ['127.0.0.1']; };\r\n\r\n// Create the server\r\napp.use(ipfilter(ips, {mode: 'allow'}));\r\n\r\nmodule.exports = app;\r\n```\r\n\r\n## Error Handling\r\n\r\nWhen an IP is denied, an IpDeniedError will be thrown by the middleware. If you do not handle the error, it will cause your app to crash due to an unhandled exception. Here is an example of how to handle the error, which can also be found in the example app:\r\n\r\n```\r\nif (app.get('env') === 'development') {\r\n  app.use(function(err, req, res, _next) {\r\n    console.log('Error handler', err);\r\n    if(err instanceof IpDeniedError){\r\n      res.status(401);\r\n    }else{\r\n      res.status(err.status || 500);\r\n    }\r\n\r\n    res.render('error', {\r\n      message: 'You shall not pass',\r\n      error: err\r\n    });\r\n  });\r\n}\r\n```\r\n\r\nYou will need to require the `IpDeniedError` type in order to handle it.\r\n\r\n\r\n## Options\r\n\r\n| Property      | Description   | Type  | Default|\r\n| ------------- |-------------| -----|--------|\r\n| mode   | whether to *deny* or *allow* to the IPs provided | string|deny|\r\n| log   | console log actions | boolean|true|\r\n| logLevel | level of logging (*all*,*deny*,*allow*) | string | all\r\n| allowedHeaders | an array of strings for header names that are acceptable for retrieving an IP address | array | [] |\r\n| excluding   | routes that should be excluded from ip filtering | array|[]|\r\n| detectIp | define a custom function that takes an Express request object and returns an IP address to test against | function | built-in detection |\r\n\r\n> A note on detectIp\r\n\r\nIf you need to parse an IP address in a way that is not supported by default, you can write your own parser and pass that to `ipfilter`.\r\n\r\n```\r\nfunction customDetection(req){\r\n  var ipAddress;\r\n\r\n  ipAddress = req.connection.remoteAddress.replace(/\\//g, '.');\r\n\r\n  return ipAddress;\r\n}\r\n\r\nipfilter(ids, {detectIp: customDetection});\r\n\r\n```\r\n\r\n## Contributing\r\n\r\nSee the `CONTRIBUTING.MD` document for more information on contributing.\r\n\r\n### Building from source\r\n\r\nYou can run `grunt` to build the source.  This will run `eslint` and `babel` against `src/ipfilter.js`.\r\n\r\nThere is an included `example` project that will load the package from the local build for testing.\r\n\r\n### Running Tests\r\n\r\nRun tests by using\r\n\r\n`grunt test`\r\n\r\nThis will run `eslint`,`babel`, and `mocha` and output coverage data into `coverage`.  Any pull request you submit needs to be accompanied by a test.\r\n\r\n## Changelog\r\n\r\n0.0.1\r\n\r\n* First revision - forked from express-filter\r\n* Updated all packages\r\n* Removed vulnerabilities\r\n\r\n## Credits\r\n\r\nBaM Interactive - [code.bamideas.com](http://code.bamideas.com)\r\n","readmeFilename":"README.md"}