Privat is a very simple password protection for Laravel projects. It's useful for websites in a staging state.
composer require code16/privatPRIVAT_ENABLED=true
PRIVAT_PASSWORD=mypasswordBy default, Privat will protect the web middleware group. If you want to impact other groups, you can tweak the corresponding .env key:
PRIVAT_MIDDLEWARE_GROUP=web,adminYou can exclude some hosts or URLs from Privat:
PRIVAT_EXCEPTED_URLS="/login,/admin"
PRIVAT_EXCEPTED_HOSTS="admin.mywebsite.com"If you need to present a public waiting page, set the waiting page view name in the PRIVAT_WAITING_VIEW env key:
PRIVAT_WAITING_VIEW="demo.waiting"From then, all requests without the Privat registration will be redirected to /privat_waiting which will render the configured view, except /privat, which will still present the Privat form.
Of course, you can publish the config file instead of using env variables (even if we think it’s more convenient for such a tool):
php artisan vendor:publish --provider="Code16\Privat\PrivatServiceProvider"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).
MIT
