Looking to hire Laravel developers? Try LaraJobs

laravel-simple-basic-auth maintained by hryha

Description
Basic auth for Laravel
Author
Last update
2026/03/18 11:04 (2.x-dev)
License
Downloads
1 502

Comments
comments powered by Disqus

Simple Basic Auth for Laravel

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