PHP code example of ozankurt / laravel-security

1. Go to this page and download the library: Download ozankurt/laravel-security 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/ */

    

ozankurt / laravel-security example snippets


Route::group(['middleware' => 'firewall.all'], function () {
    Route::get('/', 'HomeController@index');
});

Route::group(['middleware' => 'firewall.whitelist'], function () {
    Route::get('/admin', 'AdminController@index');
});

Route::group(['middleware' => 'firewall.url'], function () {
    Route::get('/admin', 'AdminController@index');
});

firewall.all

firewall.agent
firewall.bot
firewall.geo
firewall.ip
firewall.lfi
firewall.php
firewall.referrer
firewall.rfi
firewall.session
firewall.sqli
firewall.swear
firewall.url
firewall.whitelist
firewall.xss
firewall.keyword

    use App\Models\User;
    use Illuminate\Support\Facades\Gate;

    /**
     * Bootstrap any application services.
     */
    public function boot(): void
    {
        Gate::define('viewSecurityDashboard', function (?User $user) {
            return $user?->id === 1;
        });

        // ...
    }
bash
php artisan vendor:publish --tag=security
bash
php artisan migrate