Download the PHP package juanpagfe/slim-ip-filter without Composer
On this page you can find all versions of the php package juanpagfe/slim-ip-filter. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download juanpagfe/slim-ip-filter
More information about juanpagfe/slim-ip-filter
Files in juanpagfe/slim-ip-filter
Package slim-ip-filter
Short Description A Slim middleware to restrict/allow ip addresses that will access to your routes
License GPL-2.0+
Informations about the package slim-ip-filter
Slim Framework IP Filter
A slim middleware to filter ip addresses that will access to your routes. It internally uses Ip
Validator of Respect/Validation and rka-ip-address-middleware. Is based on slim-restrict-route
Install
Via Composer
Requires Slim 3.0.0 or newer.
Usage
You have to register also the RKA\Middleware\IpAddress
middleware to correctly read the ip address.
In most cases you want to register Jpgfe\Slim\IpFilter
for a single route, however,
as it is middleware, you can also register it for all routes.
Register per route
Register for all routes
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.*')
).
You can find more syntax information on the Ip
validator documentation and in its Unit Test class.
Testing
Contributing
Please see CONTRIBUTING for details.
Credits
All versions of slim-ip-filter with dependencies
akrabat/rka-ip-address-middleware Version ~0.4
respect/validation Version ^1.0