Protect pages from access with a universal username/password combination (set by configuration).
Spatie is a webdesign agency in Antwerp, Belgium. You'll find an overview of all our open source projects on our website.
You're free to use this package (it's MIT-licensed), but if it makes it to your production environment you are required to send us a postcard from your hometown, mentioning which of our package(s) you are using.
Our address is: Spatie, Samberstraat 69D, 2060 Antwerp, Belgium.
The best postcards will get published on the open source page on our website.
You can install the package via Composer:
$ composer require spatie/laravel-littlegatekeeper
Start by registering the package's the service provider:
// config/app.php (L5)
'providers' => [
// ...
'Spatie\LittleGateKeeper\LittleGateKeeperServiceProvider',
],
Next, publish the config files:
$ php artisan vendor:publish --provider="Spatie\LittleGateKeeper\LittleGateKeeperServiceProvider" --tag="config"
Finally, register the middleware:
// app/Http/Kernel.php
protected $routeMiddleware = [
// ...
'littlegatekeeper' => \Spatie\LittleGateKeeper\AuthMiddleware::class,
];
First set up the username and password in your configuration file.
You can protect your routes by applying the middleware:
Route::get('/', ['middleware' => 'littlegatekeeper', function () {
return view('protectedpage');
}]);
If a user isn't logged in, he will be redirected to the url set in the config file (littlegatekeeper.authRoute
).
/**
* @param array $credentials Format: ['username' => '...', 'password' => '...']
* @return bool
*/
public function attempt($credentials)
/**
* @return bool
*/
public function isAuthenticated()
protected function logout()
Please see CHANGELOG for more information what has changed recently.
Please see CONTRIBUTING for details.
If you discover any security related issues, please email freek@spatie.be instead of using the issue tracker.
Spatie is a webdesign agency in Antwerp, Belgium. You'll find an overview of all our open source projects on our website.
The MIT License (MIT). Please see License File for more information.