npm

Need private packages and team management tools?Check out npm Orgs. »

g4js-firewall

0.1.2 • Public • Published

g4js-firewall Build Status Code Climate Test Coverage

Simple pattern based firewall that supports roles and HTTP methods.

Install

$ npm install g4js-firewall

Usage

Require the module:

var Firewall = require('g4js-firewall').Firewall;

Add some rules:

var firewall = new Firewall();
 
// admin path restricted to admin role with all methods allowed
firewall.addRule('^/admin', 'admin', '*');
 
// admin path restricted to admin role with all methods allowed
firewall.addRule('^/orders', ['user','admin'], ['GET','PUT','POST']);
 
// signup path restricted to readonly role using POST method
firewall.addRule('^/signup', 'readonly', 'POST');
 
// shop path restricted to readonly role using GET method
firewall.addRule('^/shop', 'readonly', 'GET');

Run some checks:

// returns matching rule if match found
var matchingRule = firewall.check('/admin', ['admin'], 'GET');
 
// returns undefined if no matching rules found
var noBueno = firewall.check('/admin', 'hog_rider', 'GET');
 
// express middleware coming soon...
 

License

MIT

Contribute

Pull Requests always welcome, as well as any feedback or issues. Made with OSS <3 and brought to you by #teamgorgeous.

install

npm i g4js-firewall

Downloadsweekly downloads

4

version

0.1.2

license

MIT

homepage

github.com

repository

Gitgithub

last publish

collaborators

  • avatar
Report a vulnerability