Download the PHP package fgreinus/antonioribeiro-firewall without Composer
On this page you can find all versions of the php package fgreinus/antonioribeiro-firewall. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package antonioribeiro-firewall
Firewall
A Laravel package to help you block IP addresses from accessing your application or just some routes
Concepts
Blacklist
All IP addresses in those lists will no be able to access routes filtered by the blacklist filter.
Whitelist
Those IP addresses can
- Access blacklisted routes even if they are in a range of blacklisted IP addresses.
- Access 'allow whitelisted' filtered routes.
- If a route is filtered by the 'allow whitelisted' filter and the IP is not whitelisted, the request will be redirected to an alternative url or route name.
Playground & Bootstrap App
Click here to see it working and in case you need a help figuring out things, try this repository.
Playground's screenshot:
Routes
This package provides two middleware groups to use in your routes:
'fw-block-bl'
: to block all blacklisted IP addresses to access filtered routes
'fw-allow-wl'
: to allow all whitelisted IP addresses to access filtered routes
So, for instance, you could have a blocking group and put all your routes inside it:
Or you could use both. In the following example the allow group will give free access to the 'coming soon' page and block or just redirect non-whitelisted IP addresses to another, while still blocking access to the blacklisted ones.
IPs lists
IPs (white and black) lists can be stored in array, files and database. Initially database access to lists is disabled, so, to test your Firewall configuration you can publish the config file and edit the blacklist
or whitelist
arrays:
The file (for instance /usr/bin/firewall/blacklisted.txt
) must contain one IP, range or file name per line, and, yes, it will search for files recursivelly, so you can have a file of files if you need:
Redirecting non-whitelisted IP addresses
Non-whitelisted IP addresses can be blocked or redirected. To configure redirection you'll have to publish the config.php
file and configure:
Artisan Commands
To blacklist or whitelist IP addresses, use the artisan commands:
Exclusive for database usage
This is a result from firewall:list
:
Facade
You can also use the Firewall Facade
to manage the lists:
Return a blocking access response:
Suspicious events will be (if you wish) logged, so tail
it:
Blocking Whole Countries
You can block a country by, instead of an ip address, pass country:<2-letter ISO code>
. So, to block all Brazil's IP addresses, you do:
You will have to add this requirement to your composer.json
file:
or
You can find those codes here: isocodes
Session Blocking
You can block users from accessing some pages only for the current session, by using those methods:
Firewall::whitelistOnSession($ip);
Firewall::blacklistOnSession($ip);
Firewall::removeFromSession($ip);
Installation
Compatible with
- Laravel 4+ and 5+
Installing
Require the Firewall package using Composer:
Add the Service Provider to your app/config/app.php:
Add the Facade to your app/config/app.php:
Add the Middleware groups fw-block-bl
and fw-allow-wl
to your app/Http/Kernel.php
Note: You can add other middleware you have already created to the new groups by simply
adding it to the fw-allow-wl
or fw-block-bl
middleware group.
Create the migration:
Migrate it
To publish the configuration file you'll have to:
Laravel 4
Laravel 5
TODO
- Tests, tests, tests.
Author
License
Firewall is licensed under the BSD 3-Clause License - see the LICENSE
file for details
Contributing
Pull requests and issues are more than welcome.
All versions of antonioribeiro-firewall with dependencies
illuminate/support Version ~4|~5
illuminate/cache Version ~4|~5
illuminate/filesystem Version ~4|~5
fgreinus/antonioribeiro-support Version ^0.7