Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mares29/laravel-ip-filter
Simple IP access filter for Laravel 5+
https://github.com/mares29/laravel-ip-filter
ipfilter laravel laravel-5-package laravel-middleware laravel5
Last synced: 19 days ago
JSON representation
Simple IP access filter for Laravel 5+
- Host: GitHub
- URL: https://github.com/mares29/laravel-ip-filter
- Owner: mares29
- Created: 2018-01-31T22:49:14.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2018-10-09T09:52:17.000Z (about 6 years ago)
- Last Synced: 2024-11-15T07:48:50.595Z (about 2 months ago)
- Topics: ipfilter, laravel, laravel-5-package, laravel-middleware, laravel5
- Language: PHP
- Homepage:
- Size: 6.84 KB
- Stars: 2
- Watchers: 1
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# IP Filter for Laravel 5 Application
This package provide simple way to filter user access by IP addresses for your Laravel 5 application.
## Install
Via Composer
``` bash
$ composer require mares29/laravel-ip-filter
```Laravel 5.5+ automaticly register service provider and set Alias thanks to auto-discovery. With lower laravel version add to **app.php**
``` php
'providers' => [
\Mares29\Breadcrumb\FilterIpServiceProvider::class,
]
```## Usage
Export filter config.
``` terminal
php artisan vendor:publish --provider="Mares29\IpFilter\FilterIpServiceProvider"
```By default the filter is active only on **production** environment, but you can specify Your own settings in config file.
``` php
// Env - only use filter on listed environments
'env' => ['production'],
```Use one of **black list** or **white list** method. For example, allow acces only from ip address *127.0.0.1*.
``` php
// White list - List of allowed IP addresses
'allowed' => [
'127.0.0.1'
],// Black list - List of denied IP addresses
'denied' => [],
```Add middleware for all Your web routes.
``` php
protected function mapWebRoutes()
{
Route::middleware('web')
->middleware('filterIp')
->namespace($this->namespace)
->group(base_path('routes/web.php'));
}
```
Or just for specific routes.``` php
Route::get('/', function () {
return view('welcome');
})->middleware('filterIp');
```## Credits
- [Karel Mares](https://github.com/mares29)
## License
The MIT License (MIT). Please see [License File](LICENSE.md) for more information.