Skip to content
This repository has been archived by the owner on Feb 16, 2021. It is now read-only.

Mombuyish/Laravel-accessible-IPs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Laravel Accessible IPs

Build Status Total Downloads Latest Stable Version License License

Accessible IPs for Laravel. Supported allowed ip and proxy server.

Requirement

laravel 5.1 - 5.4.

Installation

Install via composer

$ composer require yish/laravel-accessible-ip

You need to register service provider in config/app.php, also, you can binding AppServiceProvider on register.

Notice You must register provider after Illuminate\Http\Request.

    'providers' => [
    ...
    /*
     * Package Service Providers...
     */
    Mombuyish\AccessibleIP\AccessibleIPServiceProvider::class,
    ...

Next, navigate to app/Http/Middleware/Kernel.php, adding middleware

protected $routeMiddleware = [
        'access-ip' => \Mombuyish\AccessibleIP\Middleware\AccessibleIPAddress::class,
    ];

Finally, publish the config.

$ php artisan vendor:publish --provider="Mombuyish\AccessibleIP\AccessibleIPServiceProvider"

You can configrate on config access-ip.php

🎉🎉 Supported CI/DR !! 🎉🎉

Including 127.0.0.1 inside, so you don't need add it.

'allowed' => [
        '123.11.22.33',
        '123.11.0.0/32'
    ],

If you have proxies server on front, you should be place proxies:

🎉🎉 Supported CI/DR !! 🎉🎉

'proxies' => [
        env('PROXY_SERVER_IP'),
        '123.11.0.0/32'
    ],

You can use on routing middleware, for example:

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

or you can do this:

Route::group(['middleware' => ['access-ip']], function() {
    Route::get('/', function () {
        return view('welcome');
    });
});

Exception

When you denied by middleware, you will get 403 Forbidden. You can use app/Exceptions/Handler.php to change exception do something.

It will get same things.

About

Accessible IPs for Laravel. Supported allowed ip and proxy server.

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages