2017 © Pedro Peláez
 

library laravel-route-restrictor

Laravel middleware to restrict a site or specific routes using HTTP basic authentication

image

divineomega/laravel-route-restrictor

Laravel middleware to restrict a site or specific routes using HTTP basic authentication

  • Thursday, July 5, 2018
  • by DivineOmega
  • Repository
  • 2 Watchers
  • 4 Stars
  • 153 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 2 Forks
  • 0 Open issues
  • 11 Versions
  • 13 % Grown

The README.md

🚫 Laravel Route Restrictor

Laravel Route Restrictor is a middleware package designed to restrict a entire site or specific routes using HTTP basic authentication. It is compatible with Laravel 5.1 and above., (*1)

Setup

  1. Run composer require divineomega/laravel-route-restrictor.
  2. Add DivineOmega\LaravelRouteRestrictor\Providers\LaravelRouteRestrictorServiceProvider::class to the $providers array in your config/app.php file.
  3. Run php artisan vendor:publish --provider="DivineOmega\LaravelRouteRestrictor\Providers\LaravelRouteRestrictorServiceProvider".
  4. Add \DivineOmega\LaravelRouteRestrictor\Http\Middleware\BasicAuthentication::class to the $middleware array in your app/Http/Kernel.php file.
  5. Add 'routeRestrictor' => \DivineOmega\LaravelRouteRestrictor\Http\Middleware\BasicAuthentication::class to the $routeMiddleware array in your app/Http/Kernel.php file.
  6. Add RewriteRule .* - [E=REMOTE_USER:%{HTTP:Authorization}] immediately below RewriteEngine On in your public/.htaccess file. This is required for web servers that are configured to use CGI as their PHP handler.

Global restriction

In order to restrict all routes in your Laravel application, just add the global username and password to your .env file as follows. Ensure you change the username and password values., (*2)

ROUTE_RESTRICTOR_GLOBAL_USERNAME=username
ROUTE_RESTRICTOR_GLOBAL_PASSWORD=password

Your entire application will then be protected by these details, unless a route specific restriction is in place., (*3)

Alternatively, you can modify the global restriction username and password in your config/laravel-route-restrictor.php configuration file., (*4)

Restricting specific routes

To restrict specific routes, you must edit your routes file. Simply surround the route or routes you want to restrict with the following route group code. Ensure you change the username and password middleware parameters., (*5)

Route::group(['middleware' => 'routeRestrictor:username,password'], function () {
    // Route(s) to restrict go here
});

Note: If you have both route specific restrictions and a global restriction, both will work, but route specific restrictions will take priority., (*6)

Excluding specific routes from restriction

If you wish to exclude one or more routes from restriction, you must edit your routes file. Simply surround the route or routes you want to exclude with the following route group code., (*7)

Route::group(['middleware' => 'routeRestrictor:disable'], function () {
    // Route(s) to exclude from restriction go here
});

The Versions

05/07 2018

dev-master

9999999-dev https://github.com/DivineOmega/laravel-route-restrictor

Laravel middleware to restrict a site or specific routes using HTTP basic authentication

  Sources   Download

LGPL3 LGPL-3.0-only

The Requires

 

laravel password restriction password restriction basic authentication

05/07 2018

v2.1.6

2.1.6.0 https://github.com/DivineOmega/laravel-route-restrictor

Laravel middleware to restrict a site or specific routes using HTTP basic authentication

  Sources   Download

LGPL-3.0-only

The Requires

 

laravel password restriction password restriction basic authentication

15/06 2018

v2.1.4

2.1.4.0 https://github.com/DivineOmega/laravel-route-restrictor

Laravel Route Restrictor - Laravel 5.1 Middleware to restrict a site or specific routes using HTTP basic authentication

  Sources   Download

LGPL-3.0-only

The Requires

 

laravel password restriction password restriction basic authentication

20/02 2018

v2.1.3

2.1.3.0 https://github.com/DivineOmega/laravel-route-restrictor

Laravel Route Restrictor - Laravel 5.1 Middleware to restrict a site or specific routes using HTTP basic authentication

  Sources   Download

LGPL-3.0-only

The Requires

 

laravel password restriction password restriction basic authentication

10/05 2017

v2.1.2

2.1.2.0 https://github.com/DivineOmega/laravel-route-restrictor

Laravel Route Restrictor - Laravel 5.1 Middleware to restrict a site or specific routes using HTTP basic authentication

  Sources   Download

LGPL3

The Requires

 

laravel password restriction password restriction basic authentication

29/03 2017

v2.1.1

2.1.1.0 https://github.com/DivineOmega/laravel-route-restrictor

Laravel Route Restrictor - Laravel 5.1 Middleware to restrict a site or specific routes using HTTP basic authentication

  Sources   Download

LGPL3

The Requires

 

laravel password restriction password restriction basic authentication

29/03 2017

v2.1.0

2.1.0.0 https://github.com/DivineOmega/laravel-route-restrictor

Laravel Route Restrictor - Laravel 5.1 Middleware to restrict a site or specific routes using HTTP basic authentication

  Sources   Download

LGPL3

The Requires

 

laravel password restriction password restriction basic authentication

29/03 2017

v2.0.0

2.0.0.0 https://github.com/DivineOmega/laravel-route-restrictor

Laravel Route Restrictor - Laravel 5.1 Middleware to restrict a site or specific routes using HTTP basic authentication

  Sources   Download

LGPL3

The Requires

 

laravel password restriction password restriction basic authentication

28/03 2017

v1.0.1

1.0.1.0 https://github.com/DivineOmega/laravel-route-restrictor

Laravel Route Restrictor - Laravel 5.1 Middleware to restrict a site or specific routes using HTTP basic authentication

  Sources   Download

LGPL3

The Requires

 

laravel password restriction password restriction basic authentication

29/11 2016

v1.1

1.1.0.0 https://github.com/DivineOmega/laravel-route-restrictor

Laravel Route Restrictor - Laravel 5.1 Middleware to restrict a site or specific routes using HTTP basic authentication

  Sources   Download

LGPL3

The Requires

 

laravel password restriction password restriction basic authentication

01/09 2016

v1.0

1.0.0.0 https://github.com/DivineOmega/laravel-route-restrictor

Laravel Route Restrictor - Laravel 5.1 Middleware to restrict a site or specific routes using HTTP basic authentication

  Sources   Download

LGPL3

The Requires

 

laravel password restriction password restriction basic authentication