lokhman / silex-firewall
Silex 2.0+ service provider for firewall rules
2.0.0
2017-05-16 13:14 UTC
Requires
- silex/silex: ~2.0
This package is auto-updated.
Last update: 2024-12-16 22:10:46 UTC
README
Firewall rules service provider for Silex 2.0+ micro-framework.
This project is a part of
silex-tools
library.
Installation
You can install silex-firewall
with Composer:
composer require lokhman/silex-firewall
Documentation
Register FirewallServiceProvider
with firewall allow or/and deny settings:
use Lokhman\Silex\Provider\FirewallServiceProvider;
$app->register(new FirewallServiceProvider(), [
'firewall.options' => [
'allow' => ['127.0.0.1', '::1'], // as array
'deny' => '127.0.0.1, ::1', // as string
],
]);
// override default blocking function
$app['firewall.blocker'] = $app->protect(function (Request $request) {
return JsonResponse(['deny' => $request->getClientIp()]);
});
License
Library is available under the MIT license. The included LICENSE file describes this in detail.