/privat

Simple password protection for Laravel projects in staging state.

Primary LanguagePHP

This package is deprecated, a backward compatible v2 version of it is available here: code16/privat

Privat

Private is a very simple password protection for Laravel projects. It's useful for websites in a staging state.

Screenshot

Usage

Install with composer

composer require dvlpp/privat

Add Privat Service Provider (except for Laravel 5.5+)

Add the following line in the providers section of your config/app.php file:

\Dvlpp\Privat\PrivatServiceProvider::class

Add Privat middleware in your project

Add the following line at the end of the $middleware array of the app/Http/Kernel file:

\Dvlpp\Privat\PrivatMiddleware::class

Set Privat config

First create the privat config file:

php artisan vendor:publish --provider="Dvlpp\Privat\PrivatServiceProvider"

And then edit the new /config/privat.php accordingly (nothing fancy), or even better, add this keys in your .env file:

  • PRIVAT_RESTRICTED=true
  • PRIVAT_PASSWORD=mypassword

Exceptions

The except config param is meant to contain an array of excluded urls (those url won't be protected by Privat).

How does it work

Quite simple: if the given password is correct, Privat sets a session property, and look for it on each request. So, obviously, Privat won't work on non session based systems (an API for instance).

License

WTFPL