I have used the following repository
https://github.com/elic-dev/laravel-site-protection
To install:
composer require elic-dev/laravel-site-protection
Open [app/Http/Kernel.php]
Add this variable in Middleware array (protected $middleware = [];)
\ElicDev\SiteProtection\Http\Middleware\SiteProtection::class,
Add passwords on .env file
SITE_PROTECTION_PASSWORDS=password1,password2
That’s it!