This Twill Capsule is intended to enable developers to configure Basic Auth on their applications.
You add as many domains as you need and configure different passwords for each. Once you enable the all domains (*) entry, the same configuration will be used for all, and all other domains will be hidden.
A middleware is automatically added to all web routes, but you can configure this behaviour or even disable it to configure your middleware yourself:
'middleware' => [
'automatic' => true,
'groups' => ['web'],
'class' => \A17\TwillHttpBasicAuth\Http\Middleware::class,
],If you don't want to share a single username and password with everyone that will access your pages, you can configure the package to allow existing users, both on Twill (CMS) and/or Laravel (frontend), to use their own passwords to pass Basic Auth.
composer require area17/twill-http-basic-authphp artisan vendor:publish --provider="A17\TwillHttpBasicAuth\ServiceProvider"/**
* Register any application services.
*
* @return void
*/
public function register()
{
\A17\TwillHttpBasicAuth\Services\Helpers::load();
}The configuration works both on .env or in the CMS settings. If you set them on .env the CMS settings will be disabled and overloded by .env.
TWILL_HTTP_BASIC_AUTH_ENABLED=true
TWILL_HTTP_BASIC_AUTH_USERNAME=frontend
TWILL_HTTP_BASIC_AUTH_PASSWORD=secret
TWILL_HTTP_BASIC_AUTH_RATE_LIMITING_ATTEMPTS=5
TWILL_HTTP_BASIC_AUTH_TWILL_DATABASE_LOGIN_ENABLED=true
TWILL_HTTP_BASIC_AUTH_LARAVEL_DATABASE_LOGIN_ENABLED=truePlease contribute to this project by submitting pull requests.

