Accessible IPs for Laravel. Supported allowed ip and proxy server.
Switch branches/tags
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
config
src
tests
.gitignore
.travis.yml
README.md
composer.json
phpunit.xml

README.md

Build Status Total Downloads Latest Stable Version License License

Laravel Accessible IPs

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

Required:

  • laravel 5.3 or later.

Installation

As others package, use composer install this package. For example:

$ composer require yish/laravel-accessible-ip

Secondly, 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,
    ...

Thirdly, Going to app/Http/Middleware/Kernel.php, adding middleware

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

Fourthly, publish config.

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

You can do 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'
    ],

Finally, 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.