PHP code example of arkitecht / firewall

1. Go to this page and download the library: Download arkitecht/firewall library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

arkitecht / firewall example snippets


Route::group(['middleware' => 'fw-block-bl'], function () 
{
    Route::get('/', 'HomeController@index');
});

Route::group(['middleware' => 'fw-block-bl'], function () 
{
    Route::get('coming/soon', function()
    {
        return "We are about to launch, please come back in a few days.";
    });

    Route::group(['middleware' => 'fw-allow-wl'], function () 
    {
        Route::get('/', 'HomeController@index');
    });
});

'blacklist' => array(
    '127.0.0.1',
    '192.168.17.0/24'
    '127.0.0.1/255.255.255.255'
    '10.0.0.1-10.0.0.255'
    '172.17.*.*'
    'country:br'
    '/usr/bin/firewall/blacklisted.txt',
),

'redirect_non_whitelisted_to' => 'coming/soon',

$ip = '10.17.12.1';

$whitelisted = Firewall::isWhitelisted($ip);
$blacklisted = Firewall::isBlacklisted($ip);

Firewall::whitelist($ip);
Firewall::blacklist($ip, true); /// true = force in case IP is whitelisted

if (Firewall::whichList($ip))  // returns false, 'whitelist' or 'blacklist'
{
    Firewall::remove($ip);
}

return Firewall::blockAccess();

Firewall::whitelistOnSession($ip);
Firewall::blacklistOnSession($ip);
Firewall::removeFromSession($ip);

PragmaRX\Firewall\Vendor\Laravel\ServiceProvider::class,

'Firewall' => PragmaRX\Firewall\Vendor\Laravel\Facade::class,

protected $middlewareGroups = [
        ...
        
        'fw-block-bl' => [
            \PragmaRX\Firewall\Middleware\FirewallBlacklist::class,
        ],
        'fw-allow-wl' => [
            \PragmaRX\Firewall\Middleware\FirewallWhitelist::class,
        ],        
];

php artisan tail

php artisan firewall:blacklist country:br

php artisan firewall:tables

php artisan migrate

php artisan config:publish pragmarx/firewall

php artisan vendor:publish