connect-access
Access controls (ACLs) by location as a Connect middleware. Inspired by nginx's http_access_module.
Installation
$ npm install connect-access
Basic Usage
access(String path, Array rules)
var access = require('connect-access');
var rules = [
'192.168.1.1',
'10.0.0.0/8',
'127.0.0.1',
'-all',
];
var app = connect()
.use(access('/private/*', rules))
.use(function(req, res, next) {
res.end('Hello world');
});
ACLs
There are 2 ways to declare a list of acls.
- Explicitly allow an IP/CIDR
- Explicitly disallow an IP/CIDR
To allow or disallow, the ip rule is prefixed with a +
or -
. If no qualifier is specified, it's assumed to allow
.
Rules are executed first to last and ends when the first rule is matched. If no match is found, assumes allow everything.
Example Rules
'all'
'127.0.0.1'
'10.0.0.0/8'
'-127.0.0.1'
'-10.0.0.0/8'
'-all'