| Package Data | |
|---|---|
| Maintainer Username: | DivineOmega | 
| Package Create Date: | 2016-02-29 | 
| Package Last Update: | 2019-09-09 | 
| Home Page: | |
| Language: | PHP | 
| License: | LGPL-3.0-only | 
| Last Refreshed: | 2025-10-29 03:02:34 | 
| Package Statistics | |
|---|---|
| Total Downloads: | 4,435 | 
| Monthly Downloads: | 0 | 
| Daily Downloads: | 0 | 
| Total Stars: | 4 | 
| Total Watchers: | 1 | 
| Total Forks: | 2 | 
| Total Open Issues: | 0 | 
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.
composer require divineomega/laravel-route-restrictor.DivineOmega\LaravelRouteRestrictor\Providers\LaravelRouteRestrictorServiceProvider::class to the $providers array in your config/app.php file.php artisan vendor:publish --provider="DivineOmega\LaravelRouteRestrictor\Providers\LaravelRouteRestrictorServiceProvider".\DivineOmega\LaravelRouteRestrictor\Http\Middleware\BasicAuthentication::class to the $middleware array in your app/Http/Kernel.php file.'routeRestrictor' => \DivineOmega\LaravelRouteRestrictor\Http\Middleware\BasicAuthentication::class to the $routeMiddleware array in your app/Http/Kernel.php file.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.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.
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.
Alternatively, you can modify the global restriction username and password in your config/laravel-route-restrictor.php configuration file.
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.
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.
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.
Route::group(['middleware' => 'routeRestrictor:disable'], function () {
    // Route(s) to exclude from restriction go here
});