Weave Code
Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Site Guard Laravel Package

mylonia/site-guard

View on GitHub
Deep Wiki
Context7

Site Guard

Protect your site from random visitors with a simple plain-text password guard, configurable in your .env file.

Apply the middleware to your service provider of choice, and this package will prevent visiting all routes by default. Instead, a password prompt will be displayed:

It is possible to customize the password page, and to customize which routes are accessible regardless of Site Guard's activation status.

Installation

You can install the package with composer:

composer require mylonia/site-guard

Usage

Configuring a password

First, set these environment variables:

SITE_GUARD_PASSWORD=your-passphrase-here

Registering the middleware

You can register the middleware under the conditions of your liking, for example in AppServiceProvider:

use Mylonia\SiteGuard\SiteGuardMiddleware;

public function boot(Router $router): void
{
    if (! $this->app->environment('production')) {
        $router->pushMiddlewareToGroup('web', SiteGuardMiddleware::class);
    }
}

This ensures that the production website is unaffected, but any potential local or staging setup will display the message. You can tweak this as desired.

Publishing assets

You can also exclude particular routes by customising the config file.

php artisan vendor:publish --provider="Mylonia\SiteGuard\SiteGuardServiceProvider"

This will publish the custom views and the site-guard config file. You can further customise the configuration file this way.

For example, you can adapt excluded_routes to exclude particular routes. By default, all site_guard.* routes are excluded, but you can add more this way. (You can use wildcards.)

You can also customise which middleware is required to run when the Site Guard routes are visited, which may be necessary depending on your project.

Testing

To run the test suite:

composer test

To run all steps (including linting, static checks, etc.) please run:

composer verify

Security Vulnerabilities

Please get in touch with [email protected] to report a vulnerability.

Credits

License

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

Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
hsluv/hsluv
seampact/codegen
seampact/hooks
seampact/ir
mehedimi/laravel-amp-mail
happones/laravel-vue-i18n-generator
jwerd/inertia-table
siberfx/flysystem-wasabi
hollyit/token-replace
ippanelcom/laravel-sdk
adachsoft/changelog-linter
adachsoft/collection
payerurl/telegrambot-crypto-payment-instant-payout
dskripchenko/laravel-hybrid-search
riorizkyrainey/lara-ced
mehedimi/static-vel
zharp/zharp
nonsapiens/bigquery-model-sync
lgu-bayambang-ict-office/lgu-laravel-development-standards
andydefer/laravel-support