area17 / twill-http-basic-auth
A Twill Capsule to add and handle HTTP Basic Auth
Fund package maintenance!
area17
Requires
- php: >=8.0
- area17/http-basic-auth: 1.x-dev
- area17/twill: ^2.7|^3.0
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.0
- nunomaduro/larastan: ^2.0
- orchestra/testbench: ^7.11
- phpstan/phpstan: ^1.8
This package is auto-updated.
Last update: 2023-03-28 12:20:48 UTC
README
This Twill Capsule is intended to enable developers to configure Basic Auth on their applications.
Domains
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.
Middleware
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, ],
Using authentication
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.
Installing
Require the Composer package:
composer require area17/twill-http-basic-auth
Publish the configuration
php artisan vendor:publish --provider="A17\TwillHttpBasicAuth\ServiceProvider"
Load Capsule helpers by adding calling the loader to your AppServiceProvider:
/** * Register any application services. * * @return void */ public function register() { \A17\TwillHttpBasicAuth\Services\Helpers::load(); }
.env
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=true
Contribute
Please contribute to this project by submitting pull requests.