Skip to content

A Laravel Package to increase the security of your websites by preventing access for users having blocked IP Addresses.

Notifications You must be signed in to change notification settings

Mahmoud-Italy/Larasecure-ipblocker

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

26 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

IP Blocker

Scrutinizer Code Quality Code Intelligence Status Total Downloads

ib-blocker

A Laravel Package to increase the security of your websites by preventing access for users having blocked IP Addresses.

However, you can add IP Addresses as many as you want into table called ipblockers which you want to disallow access to your site from spam etc.

Installation

composer require larasecure/ip-blocker

Then publish the config

php artisan vendor:publish --tag=ipblocker
php artisan migrate

Usage

Add this middleware in Kernel.php $routeMiddleware to restrict IP Addresses

'IPBlocking' => \Larasecure\IPBlocker\Middlewares\IPBlocking::class

Add IPBlocking middleware to route group for which you want to restrict access.

  Route::group(['middleware' => 'IPBlocking'], function(){
    // you routes..
  });

or you can injected in RouteServiceProvider.php

  protected function mapApiRoutes()
    {
        Route::prefix('api')
            ->middleware(['api', 'IPBlocking'])
            ->namespace($this->namespace)
            ->group(base_path('routes/api.php'));
    }

or just add middleware to single route

  Route::get('/', function () {
    //
  })->middleware('IPBlocking');

Users will be redirect to "403 | Forbidden" page if their IP exist on ipblockers table.

Credits

License

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

About

A Laravel Package to increase the security of your websites by preventing access for users having blocked IP Addresses.

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages