Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

express-ipfilter

Package Overview
Dependencies
Maintainers
1
Versions
37
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

express-ipfilter

A light-weight IP address based filtering system

  • 0.1.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
26K
increased by7.4%
Maintainers
1
Weekly downloads
 
Created
Source

express-ipfilter: A light-weight IP address based filtering system

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.

Circle CI

Version

0.1.0

Installation

Recommended installation is with npm. To add node-ipfilter to your project, do:

npm install express-ipfilter

Usage with Express

NOTE: Starting with version 0.1.0, allow forwarded IP addresses through headers (forward, Cloudflare, Codio) are disabled by default. You must explicitly enable these features with the new settings.

Blacklisting certain IP addresses, while allowing all other IPs:

// Init dependencies
var express = require('express')
    , ipfilter = require('express-ipfilter')
    , app = express.createServer()
    ;

// Blacklist the following IPs
var ips = ['127.0.0.1'];

// Create the server
app.use(ipfilter(ips));
app.listen(3000);

Whitelisting certain IP addresses, while denying all other IPs:

// Init dependencies
var express = require('express')
    , ipfilter = require('express-ipfilter')
    , app = express.createServer()
    ;

// Whitelist the following IPs
var ips = ['127.0.0.1'];

// Create the server
app.use(ipfilter(ips, {mode: 'allow'}));
app.listen(3000);

Using CIDR subnet masks for ranges:

var ips = ['127.0.0.1/24'];

// Create the server
app.use(ipfilter(ips, {mode: 'allow'}));
app.listen(3000);

Using IP ranges:

var ips = [['127.0.0.1','127.0.0.10']];

// Create the server
app.use(ipfilter(ips, {mode: 'allow'}));
app.listen(3000);

Options

PropertyDescriptionTypeDefault
modewhether to deny or allow to the IPs providedstringdeny
logconsole log actionsbooleantrue
errorCodethe HTTP status code to use when denying accessnumber401
errorMessagethe error message to use when denying accessstringUnauthorized
allowForwardEnable or disable forwarded ip address through the request heardsbooleanfalse
allowCloudflareEnable or disable CloudFlare forwarded ip address through the request heardsbooleanfalse
allowCodioEnable or disable Codio forwarded ip address through the request heardsbooleanfalse
excludingroutes that should be excluded from ip filteringarray[]

Contributing

Building from source

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.

Running Tests

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.

Changelog

0.1.0

  • Changed default behavior of the library to disable reading forwarded IP headers. They must now be explicitly enabled.
  • Using res.send when a failure occurs to allow for different formats of errorMessage

0.0.25

  • Switched from netmask to range_check (uses ipaddr.js)
  • Added support for IPv6 CIDR
  • Fixed issue with mixed IPv4 and IPv6 rules

0.0.24

  • Added lib to version control

0.0.23

  • added codio x-real-ip header

0.0.22

  • Added IPv6 Support
  • Added build tools
  • Added test coverage and reporting

0.0.20

  • Added a setting to explicitly allow CloudFlare and Forwarded IPs. By default they are set to not allow these headers. Thanks to @longstone!

0.0.19

0.0.18

  • Fixing bug when array of CIDR blocks are used

0.0.16

  • Fixing bug when no IP address can be determined

0.0.15

  • Minor bug fix

0.0.14

  • Adding the ability to have exclusion urls

0.0.12

  • Diagnostic Options

0.0.11

  • Bug Fix for port logic

0.0.10

  • Added support for IPs with port numbers

0.0.9

  • Fixing deploy issues

0.0.8

  • Auto deploys for npm

0.0.7

  • Add support ip ranges.

0.0.6

  • Fixed a bug when using console output

0.0.5

  • Added ability to block by subnet mask (i.e. 127.0.0.1/24)
  • Added tests for cidr functionality

0.0.4

  • Add tests
  • Update docs
  • Refactor, and restyle

0.0.1

  • First revision

Credits

BaM Interactive - code.bamideas.com

Keywords

FAQs

Package last updated on 10 Aug 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc