hryha/laravel-simple-basic-auth

2.0.0 2025-03-20 09:21 UTC

This package is auto-updated.

Last update: 2025-04-03 12:44:36 UTC


README

This package provides a middleware for Basic Auth without using a database

Latest Version on Packagist Total Downloads PHP Version Laravel Version Software License

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