2017 © Pedro Peláez
 

library firewall

image

amonger/firewall

  • Wednesday, September 2, 2015
  • by haveacigaro
  • Repository
  • 1 Watchers
  • 0 Stars
  • 368 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 6 Versions
  • 0 % Grown

The README.md

Build Status, (*1)

Firewall

This is a simple library which will have some action on a route being matched., (*2)

It is useful for legacy projects where some authorisation code my be copy pasted into a header multiple times and there is no under-laying structure., (*3)

Example

Individual routes

You can define routes individually by doing the following:, (*4)


use \amonger\Firewall\Firewall; $firewall = new Firewall($_SERVER['REQUEST_URI']); $firewall ->route('/managers\/.*/') ->unless(function ($uri) use ($container) { return $container['auth']->hasRole('manager'); }) ->handle(function () { throw new _401Exception(); }) ->execute();

Multiple routes

A scenario which is more likely is that you will have a single request uri and multiple routes you'd like to handle. In this case you can use the builder to setup the firewall., (*5)

use \amonger\Firewall\Firewall;

$firewall = Firewall::getBuilder();
$firewall->setRequestUri($_SERVER['REQUEST_URI']);

$firewall
    ->route('/managers\/.*/')
    ->unless(function ($uri) use ($container) {
       return $container['auth']->hasRole('manager');
    })
    ->handle(function () {
        throw new _401Exception();
    });

$firewall
    ->route('/clients\/.*/')
    ->unless(function ($uri) use ($container) {
       return $container['auth']->hasRole('clients');
    })
    ->handle(function () {
        throw new _401Exception();
    });

Firewall::run($firewall);

The Versions

02/09 2015

dev-master

9999999-dev

  Sources   Download

MIT

The Development Requires

by Alan Monger

02/09 2015

v0.4.1

0.4.1.0

  Sources   Download

MIT

The Development Requires

by Alan Monger

27/06 2015

v0.4.0

0.4.0.0

  Sources   Download

MIT

The Development Requires

by Alan Monger

26/06 2015

v0.3.0

0.3.0.0

  Sources   Download

MIT

The Development Requires

by Alan Monger

30/05 2015

v0.2.0

0.2.0.0

  Sources   Download

MIT

The Development Requires

by Alan Monger

30/05 2015

v0.1.0

0.1.0.0

  Sources   Download

The Development Requires

by Alan Monger