voyager-inc / simple-block-blacklist-and-whitelist-ip
Simple block ip depend on blacklist and whitelist ip
Package info
github.com/phutd-voyager/simple-block-blacklist-and-whitelist-ip
pkg:composer/voyager-inc/simple-block-blacklist-and-whitelist-ip
dev-main
2024-05-24 07:30 UTC
Requires
- php: ^8.2
- illuminate/support: ^11.0
Requires (Dev)
- orchestra/testbench: ^4|^5|^6|^7|^8|^9
This package is auto-updated.
Last update: 2026-03-24 11:39:15 UTC
README
Installation
composer require voyager-inc/simple-block-blacklist-and-whitelist-ip
- Publish provider
php artisan vendor:publish --provider="VoyagerInc\SimpleBlockBlacklistAndWhiteListIp\ServiceProvider"
Now you will see two migration files create_simple_blacklist_ips_table.php and create_simple_whitelist_ips_table.php in database/migrations folder
- Run migration
php artisan migrate
Usage
- We have two new middleware with the aliases
ip-filter-whitelistandip-filter-blacklist - The
ip-filter-whitelistmiddleware allows access only from whitelisted IPs. - The
ip-filter-blacklistmiddleware always prevents access from blacklisted IPs. - We can update whitelist and blacklist in config
simple_block_blacklist_and_whitelist_ip.phpfile
<?php return [ 'block_ip_enable' => true, 'block_by' => 'config', // or database 'whitelist_ip' => [ // ], 'blacklist_ip' => [ // ], ];
- Example
Route::get('/test', function () { return 'Whitelist route'; })->middleware(['ip-filter-whitelist']); // middleware(['ip-filter-blacklist']