akaunting / laravel-firewall

Web Application Firewall (WAF) package for Laravel

Home Page:https://akaunting.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Whitelist from DB

rabol opened this issue · comments

Hi

how can I add whitelist entries from the db?

Let me answer my own question

There are several options

first make the model and the migration

e.g
php artisan make:model FirewallWhiteList --migration

edit the migration

$table->ipAddress('address');

Now... depending on what you want:

easy:
in the boot method of you AppServiceProvider

Config::set('firewall.whitelist', \App\FirewallWhiteList::all()->pluck('address')->toArray());

or create a FirewallWhiteListProvider and register it
or create a FirewallMiddleware and add it to the kernel.php or in front of the 'firewal.all' middleware in your route group

Feel free to contribute as PR.