Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
L

laravel-littlegatekeeper

> 后端框架
Open source

Protect pages from access with a universal username/password

191 stars0 likes1 views
WebsiteGitHub

About

Protect pages from access with a universal username/password

laravel-littlegatekeeper

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.

Support us

We invest a lot of resources into creating best in class open source packages. You can support us by buying one of our paid products.

We highly appreciate you sending us a postcard from your hometown, mentioning which of our package(s) you are using. You'll find our address on our contact page. We publish all received postcards on our virtual postcard wall.

Postcardware

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, Kruikstraat 22, 2018 Antwerp, Belgium.

The best postcards will get published on the open source page on our website.

Install

You can install the package via Composer:

bash
$ composer require spatie/laravel-littlegatekeeper

Start by registering the package's the service provider:

php
// config/app.php (L5)

'providers' => [
  // ...
  'Spatie\LittleGateKeeper\LittleGateKeeperServiceProvider',
],

Next, publish the config files:

bash
$ php artisan vendor:publish --provider="Spatie\LittleGateKeeper\LittleGateKeeperServiceProvider" --tag="config"

Finally, register the middleware:

php
// app/Http/Kernel.php

protected $routeMiddleware = [
    // ...
    'littlegatekeeper' => \Spatie\LittleGateKeeper\AuthMiddleware::class,
];

Usage

First set up the username and password in your configuration file or .env file

In your .env file add:

php
// ...
GATEKEEPER_USERNAME=Choose_your_username
GATEKEEPER_PASSWORD=Choose_your_secret_password

You can protect your routes by applying the middleware:

php
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).

Authenticator methods

php
/**
 * @param  array $credentials  Format: ['username' => '...', 'password' => '...']
 * @return bool
 */
public function attempt($credentials)
php
/**
 * @return bool
 */
public function isAuthenticated()
php
protected function logout()

Change log

Please see CHANGELOG for more information what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security

If you've found a bug regarding security please mail [email protected] instead of using the issue tracker.

Credits

  • Sebastian De Deyne
  • All Contributors

About Spatie

Spatie is a webdesign agency in Antwerp, Belgium. You'll find an overview of all our open source projects on our website.

License

The MIT License (MIT). Please see License File for more information.

Issues· 0 open

View all issuesOpen on GitHub

No open issues yet, or sync has not completed.

> Tags

PHPlaravelphpsecurity

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedSep 18, 2026
Category后端框架
PricingOpen source

> Related tools

N
Node.js
基于 V8 的 JavaScript 运行时
D
Django
Python 高级 Web 框架
S
Spring Boot
Java 生态主流微服务框架