hryha / laravel-simple-basic-auth
Basic auth for Laravel
2.0.0
2025-03-20 09:21 UTC
Requires
- php: ^8.2|^8.3|^8.4
- illuminate/http: ^11.0|^12.0
- illuminate/support: ^11.0|^12.0
Requires (Dev)
- ext-pdo: *
- larastan/larastan: ^3.2
- laravel/pint: ^1.21
- orchestra/testbench: ^10.1
README
This package provides a middleware for Basic Auth without using a database
Installation
Install the package via Composer:
composer require hryha/laravel-simple-basic-auth
Configuration
Configure the credentials by setting SIMPLE_BASIC_AUTH_CREDENTIALS
in the .env
file in json
format
SIMPLE_BASIC_AUTH_CREDENTIALS='{"login1": "pass1", "login2": "pass2"}'
Usage
Access is allowed to all users with the correct credentials
Route::get('/')->middleware(SimpleBasicAuth::class);
Access is allowed only to user login1
Route::get('/')->middleware(SimpleBasicAuth::using(['login1']));
Testing
Run the test:
composer test