Skip to content

Laravel IP Whitelist is a package contain middleware to allow a list of IP addresses to access a specific web resource.

License

Notifications You must be signed in to change notification settings

Alitindrawan24/laravel-ip-whitelist

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

laravel-ip-whitelist

Latest Version on Packagist Total Downloads License: MIT

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.

Contributors

About

Laravel IP Whitelist is a package contain middleware to allow a list of IP addresses to access a specific web resource.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages