Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

g4js-firewall

AllegiantAir31MIT0.1.2

Simple pattern based firewall that supports roles and HTTP methods.

acl, firewall, express, roles, permissions

readme

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.