2017 © Pedro Peláez
 

library slim-restrict-route

A Slim middleware to restrict ip addresses that will access to your routes

image

davidepastore/slim-restrict-route

A Slim middleware to restrict ip addresses that will access to your routes

  • Saturday, June 23, 2018
  • by DavidePastore
  • Repository
  • 1 Watchers
  • 16 Stars
  • 1,417 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 5 Forks
  • 0 Open issues
  • 7 Versions
  • 24 % Grown

The README.md

Slim Framework Restrict Route

![Latest version][ico-version] Build Status ![Coverage Status][ico-scrutinizer] Quality Score ![Total Downloads][ico-downloads] PSR2 Conformance, (*1)

A slim middleware to restrict ip addresses that will access to your routes. It internally uses Ip Validator of Respect/Validation and rka-ip-address-middleware., (*2)

Install

Via Composer, (*3)

``` bash $ composer require davidepastore/slim-restrict-route, (*4)


Requires Slim 3.0.0 or newer. ## Usage You have to register also the [`RKA\Middleware\IpAddress`][rka-ip-address-middleware] middleware to correctly read the ip address. In most cases you want to register `DavidePastore\Slim\RestrictRoute` for a single route, however, as it is middleware, you can also register it for all routes. ### Register per route ```php $app = new \Slim\App(); $app->add(new RKA\Middleware\IpAddress()); $options = array( 'ip' => '192.*.*.*' ); $app->get('/api/myEndPoint',function ($req, $res, $args) { //Your amazing route code })->add(new \DavidePastore\Slim\RestrictRoute\RestrictRoute($options)); $app->run();

Register for all routes

$app = new \Slim\App();

$app->add(new RKA\Middleware\IpAddress());

$options = array(
  'ip' => '192.*.*.*'
);

// Register middleware for all routes
// If you are implementing per-route checks you must not add this
$app->add(new \DavidePastore\Slim\RestrictRoute\RestrictRoute($options));

$app->get('/foo', function ($req, $res, $args) {
  //Your amazing route code
});

$app->post('/bar', function ($req, $res, $args) {
  //Your amazing route code
});

$app->run();

Ip address

You can restrict route using a different value of ip in the options given to \RestrictRoute: * any of the filters provided by PHP regarding FILTER_VALIDATE_IP (e.g.: FILTER_FLAG_NO_PRIV_RANGE); * asterisk (*) to filter ip that are in the given subnet (e.g.: 192.*); * ranges (-) to filter ip that are in the given range (e.g.: 192.168.0.0-192.168.255.255); * single ip (e.g.: 192.168.0.1-192.168.0.1); * array of ranges to filter ip (e.g.: array('192.0.0.0-192.255.255.255', '178.0.0.*'))., (*5)

You can find more syntax information on the Ip validator documentation and in its Unit Test class., (*6)

Testing

bash $ phpunit, (*7)

Contributing

Please see CONTRIBUTING for details., (*8)

Credits

The Versions

23/06 2018

dev-master

9999999-dev

A Slim middleware to restrict ip addresses that will access to your routes

  Sources   Download

GPL-2.0+

The Requires

 

The Development Requires

by Davide Pastore

middleware framework address ip slim restrict restriction

23/06 2018

v0.3.1

0.3.1.0

A Slim middleware to restrict ip addresses that will access to your routes

  Sources   Download

GPL-2.0+

The Requires

 

The Development Requires

by Davide Pastore

middleware framework address ip slim restrict restriction

19/02 2017

v0.3.0

0.3.0.0

A Slim middleware to restrict ip addresses that will access to your routes

  Sources   Download

GPL-2.0+

The Requires

 

The Development Requires

by Davide Pastore

middleware framework address ip slim restrict restriction

12/02 2017

v0.2.0

0.2.0.0

A Slim middleware to restrict ip addresses that will access to your routes

  Sources   Download

GPL-2.0+

The Requires

 

The Development Requires

by Davide Pastore

middleware framework address ip slim restrict restriction

11/01 2017

dev-add-location

dev-add-location

A Slim middleware to restrict ip addresses that will access to your routes

  Sources   Download

GPL-2.0+

The Requires

 

The Development Requires

by Davide Pastore

middleware framework address ip slim restrict restriction

12/08 2016

v0.1.1

0.1.1.0

A Slim middleware to restrict ip addresses that will access to your routes

  Sources   Download

GPL-2.0+

The Requires

 

The Development Requires

by Davide Pastore

middleware framework address ip slim restrict restriction

25/04 2016

v0.1.0

0.1.0.0

A Slim middleware to restrict ip addresses that will access to your routes

  Sources   Download

GPL-2.0+

The Requires

 

The Development Requires

by Davide Pastore

middleware framework address ip slim restrict restriction