Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

mares29/laravel-ip-filter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 

Repository files navigation

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

$ 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

'providers' => [
	\Mares29\Breadcrumb\FilterIpServiceProvider::class,
]

Usage

Export filter config.

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.

	// 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.

	// 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.

protected function mapWebRoutes()
    {
        Route::middleware('web')
             ->middleware('filterIp')
             ->namespace($this->namespace)
             ->group(base_path('routes/web.php'));
    }

Or just for specific routes.

Route::get('/', function () {
    return view('welcome');
})->middleware('filterIp');

Credits

License

The MIT License (MIT). Please see License File for more information.

About

Simple IP access filter for Laravel 5+

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

Morty Proxy This is a proxified and sanitized view of the page, visit original site.