alitindrawan24 / laravel-ip-whitelist
0.1.2
2023-05-06 20:31 UTC
Requires
- php: ^7.4|^8.0
- illuminate/support: ^8.0|^9.0|^10.0
This package is auto-updated.
Last update: 2024-11-14 20:38:34 UTC
README
Laravel IP Whitelist is a package contain middleware to allow a list of IP addresses to access a specific web resource.
Installation
You can install the package via composer:
composer require alitindrawan24/laravel-ip-whitelist
You can publish the config file with:
php artisan vendor:publish --provider="Alitindrawan24\IPWhitelist\IPWhitelistServiceProvider" --tag="config"
By default the IP Whitelist feature is disabled, to enable the feature you add this in your .env
IP_WHITELIST_ENABLE=true
You can add the list of IP that allowed in config/ip-whitelist.php using fix IP or using wildcard
/** * List of IP Whitelist. * Only IP in this list is allowed to pass the middleware. */ 'ip_whitelist' => [ // '127.0.0.1' // Localhost example // '127.0.0.*' // Using Wildcard example ],
Usage
This packages provides a middleware which can be added as a global middleware or as a single route.
// in `app/Http/Kernel.php` protected $middleware = [ // ... \Alitindrawan24\IPWhitelist\Middleware\HttpLogger::class ];
// in a routes file Route::post('/dashboard', function () { // })->middleware(\Alitindrawan24\IPWhitelist\Middleware\HttpLogger::class);
License
This project is licensed under the MIT License - see the LICENSE.md file for details.