Gathering detailed insights and metrics for @curaelabs/express-ipfilter
Gathering detailed insights and metrics for @curaelabs/express-ipfilter
Gathering detailed insights and metrics for @curaelabs/express-ipfilter
Gathering detailed insights and metrics for @curaelabs/express-ipfilter
A light-weight IP address based connection filtering system
npm install @curaelabs/express-ipfilter
Typescript
Module System
Node Version
NPM Version
JavaScript (96.36%)
HTML (2.66%)
CSS (0.98%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
MIT License
155 Commits
2 Watchers
4 Branches
1 Contributors
Updated on Jan 16, 2019
Latest Version
0.0.1
Package Id
@curaelabs/express-ipfilter@0.0.1
Unpacked Size
116.66 kB
Size
18.26 kB
File Count
28
NPM Version
6.4.1
Node Version
10.11.0
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
This 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.
0.0.1
Recommended installation is with npm. To add node-ipfilter to your project, do:
npm install @curaelabs/express-ipfilter
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.
Blacklisting certain IP addresses, while allowing all other IPs:
1// Init dependencies 2var express = require('express'), 3 ipfilter = require('express-ipfilter').IpFilter; 4 5// Blacklist the following IPs 6var ips = ['127.0.0.1']; 7 8// Create the server 9app.use(ipfilter(ips)); 10app.listen(3000);
Whitelisting certain IP addresses, while denying all other IPs:
1// Init dependencies 2// Init dependencies 3var express = require('express'), 4 ipfilter = require('express-ipfilter').IpFilter; 5 6// Whitelist the following IPs 7var ips = ['127.0.0.1']; 8 9// Create the server 10app.use(ipfilter(ips, {mode: 'allow'})); 11 12module.exports = app;
Using CIDR subnet masks for ranges:
1var ips = ['127.0.0.1/24']; 2 3// Create the server 4app.use(ipfilter(ips, {mode: 'allow'})); 5 6module.exports = app;
Using IP ranges:
1var ips = [['127.0.0.1','127.0.0.10']]; 2 3// Create the server 4app.use(ipfilter(ips, {mode: 'allow'})); 5 6module.exports = app;
Using a function to get Ips:
1var ips = function() { return ['127.0.0.1']; }; 2 3// Create the server 4app.use(ipfilter(ips, {mode: 'allow'})); 5 6module.exports = app;
When 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:
if (app.get('env') === 'development') {
app.use(function(err, req, res, _next) {
console.log('Error handler', err);
if(err instanceof IpDeniedError){
res.status(401);
}else{
res.status(err.status || 500);
}
res.render('error', {
message: 'You shall not pass',
error: err
});
});
}
You will need to require the IpDeniedError
type in order to handle it.
Property | Description | Type | Default |
---|---|---|---|
mode | whether to deny or allow to the IPs provided | string | deny |
log | console log actions | boolean | true |
logLevel | level of logging (all,deny,allow) | string | all |
allowedHeaders | an array of strings for header names that are acceptable for retrieving an IP address | array | [] |
excluding | routes that should be excluded from ip filtering | array | [] |
detectIp | define a custom function that takes an Express request object and returns an IP address to test against | function | built-in detection |
A note on detectIp
If 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
.
function customDetection(req){
var ipAddress;
ipAddress = req.connection.remoteAddress.replace(/\//g, '.');
return ipAddress;
}
ipfilter(ids, {detectIp: customDetection});
See the CONTRIBUTING.MD
document for more information on contributing.
You can run grunt
to build the source. This will run eslint
and babel
against src/ipfilter.js
.
There is an included example
project that will load the package from the local build for testing.
Run tests by using
grunt test
This will run eslint
,babel
, and mocha
and output coverage data into coverage
. Any pull request you submit needs to be accompanied by a test.
0.0.1
BaM Interactive - code.bamideas.com
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no SAST tool detected
Details
Reason
Found 0/30 approved changesets -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
53 existing vulnerabilities detected
Details
Score
Last Scanned on 2025-07-07
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More