Code Monkey home page Code Monkey logo

laravel-ip-filter's Introduction

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.

laravel-ip-filter's People

Stargazers

 avatar  avatar

Watchers

 avatar

Forkers

a-yasui

laravel-ip-filter's Issues

is there good documentation?

i can't see any good documentation about using this library, for example read and write ip on database or many etc.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.