PHPackages                             bugfix666/very-basic-auth - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Authentication &amp; Authorization](/categories/authentication)
4. /
5. bugfix666/very-basic-auth

ActiveLibrary[Authentication &amp; Authorization](/categories/authentication)

bugfix666/very-basic-auth
=========================

Laravel stateless HTTP basic auth without the need for a database

v1.0.1(1mo ago)090↓75%MITPHPPHP ^8.2

Since Jul 16Pushed 1mo agoCompare

[ Source](https://github.com/bugfix666/very-basic-auth)[ Packagist](https://packagist.org/packages/bugfix666/very-basic-auth)[ Docs](https://github.com/bugfix666/very-basic-auth)[ GitHub Sponsors](https://github.com/bugfix666)[ RSS](/packages/bugfix666-very-basic-auth/feed)WikiDiscussions master Synced 1w ago

READMEChangelog (2)Dependencies (8)Versions (3)Used By (0)

Laravel Very Basic Auth
=======================

[](#laravel-very-basic-auth)

[![Latest Version on Packagist](https://camo.githubusercontent.com/22f3989daf63e923a41706c0707ae0e8485d0ca5cf64a8bb5aefd9d0f97cc407/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6275676669783636362f766572792d62617369632d617574682e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/bugfix666/very-basic-auth)[![Total downloads](https://camo.githubusercontent.com/5a0558eee6414cdf9aac0bb4277a3e9a9c08a942a85e507231a86dd375291d27/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6275676669783636362f766572792d62617369632d617574682e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/bugfix666/very-basic-auth)[![Software License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE.md)[![Build Status](https://camo.githubusercontent.com/f3c0f9f946b839e86d199d3ea96cc6ca8910bde07cbc518322c604fd4e5c9234/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f6275676669783636362f766572792d62617369632d617574682f746573742e796d6c3f6272616e63683d6d6173746572267374796c653d666c61742d737175617265)](https://github.com/bugfix666/very-basic-auth/actions?query=workflow%3A%22Run+tests%22)

[![very-basic-auth](https://user-images.githubusercontent.com/907114/40575964-331559ce-60ef-11e8-8366-aba700fc5567.png)](https://user-images.githubusercontent.com/907114/40575964-331559ce-60ef-11e8-8366-aba700fc5567.png)

**Documentation available in:**

🇬🇧 [English](README.md)
🇯🇵 [日本語](README.jp.md)

This package allows you to add a HTTP Basic Auth filter on your routes, without the need to use a database – which the Laravel default `auth.basic`-middleware relies on.

[![Screenshot](https://user-images.githubusercontent.com/907114/29876493-3907afd8-8d9d-11e7-8068-f461855c493b.png)](https://user-images.githubusercontent.com/907114/29876493-3907afd8-8d9d-11e7-8068-f461855c493b.png)

Perfect when you want to give your clients access to your development site before you have yet to set up your database and/or models. Or perhaps your site doesn't even use a database and you still wish to keep it protected.

On failed authentication the user will get a "401 Unauthorized" response.

#### A thing to note

[](#a-thing-to-note)

While HTTP Basic Auth does give you a protection layer against unwanted visitors, it is still not strictly safe from brute-force attacks. If you are solely using this package for security, you should at least consider looking into Apache or Nginx rate-limiters to limit login attempts.

Installation
------------

[](#installation)

Via Composer

```
$ composer require bugfix666/very-basic-auth
```

Since v4.\* (for Laravel 5.5) this package uses Package Auto-Discovery for loading the service provider. Once installed you should see the message

```
Discovered Package: bugfix666/very-basic-auth

```

If you would like to manually add the provider, turn off Auto-Discovery for the package in your composer.json-file:

```
"extra": {
    "laravel": {
        "dont-discover": [
            "bugfix666/very-basic-auth"
        ]
    }
},
```

And then add the provider in the providers array (`config/app.php`).

```
'providers' => [
    Bugfix666\VeryBasicAuth\VeryBasicAuthServiceProvider::class
]
```

Configuration
-------------

[](#configuration)

Run the command `$ php artisan vendor:publish` and select `Provider: Bugfix666\VeryBasicAuth\VeryBasicAuthServiceProvider` to publish the configuration. You could also type `$ php artisan vendor:publish --provider="Bugfix666\VeryBasicAuth\VeryBasicAuthServiceProvider"` to directly publish the files.

The file `very_basic_auth.php` will then be copied to your `app/config`-folder – here you can set various options such as username and password.

#### Note

[](#note)

**There is no default password**. Upon installation you will need to set your own username and password. Please publish the packages configuration to have the ability to set these. **If left empty, basic auth will not be active**.

### Environments

[](#environments)

You may set the environments that the package should be applied for. You may simply use "`*`" to use in all environments (this is also the default).

```
'envs' => [
    '*'
],
```

Or

```
'envs' => [
    'production',
    'development',
    'local'
],
```

### Response handlers

[](#response-handlers)

When the authentication fails the response handler sends out an error response (see "Views and messages" for more about these options). By default the handler will be `\Bugfix666\VeryBasicAuth\Handlers\DefaultResponseHandler` (see `response_handler` in `very_basic_auth.php`). You may however write your own response-logic if you so choose. The only requirement is that it implements the `\Bugfix666\VeryBasicAuth\Handlers\ResponseHandler`-interface, and has an `__invoke`-method that accepts a request-object, like so:

```
use Illuminate\Http\Request;
use Bugfix666\VeryBasicAuth\Handlers\ResponseHandler;

class CustomResponseHandler implements ResponseHandler
{
    public function __invoke(Request $request)
    {
        // Do some stuff
        return response('Custom response', 401);
    }
}
```

### Views and messages

[](#views-and-messages)

In the `very_basic_auth.php`-configuration you have the ability to set a custom view instead of a message.

```
// Message to display if the user "opts out"/clicks "cancel"
'error_message'     => 'You have to supply your credentials to access this resource.',

// If you prefer to use a view with your error message you can uncomment "error_view".
// This will supersede your default response message
// 'error_view'        => 'very_basic_auth::default'
```

If you uncomment `error_view`, the middleware will try to find your specified view. You supply this value as usual (without the `.blade.php`-extention).

Usage
-----

[](#usage)

The middleware uses the `auth.very_basic`-filter to protect routes. You can either use `Route::group()` to protect multiple routes, or chose just to protect them individually.

**Group**

```
Route::group(['middleware' => 'auth.very_basic'], function() {
    Route::get('/', ['as' => 'start', 'uses' => 'StartController@index']);
    Route::get('/page', ['as' => 'page', 'uses' => 'StartController@page']);
});
```

**Single**

```
Route::get('/', [
    'as' => 'start',
    'uses' => 'StartController@index',
    'middleware' => 'auth.very_basic'
]);
```

You may also set the credentials inline;

```
Route::get('/', [
    'as' => 'start',
    'uses' => 'StartController@index',
    'middleware' => 'auth.very_basic:username,password'
]);
```

*Note:* inline credentials always take president over the `very_basic_auth.php`-configuration file.

### Generating hash for password

[](#generating-hash-for-password)

If you want to generate a hash for your password, you can use the `artisan`-command:

```
php artisan very-basic-auth:generate-password
```

It will ask you for a password, and then automatically insert the hash into your `.env`-file

Testing
-------

[](#testing)

```
$ composer test
```

or

```
$ phpunit
```

Laravel always runs in the "testing" environment while running tests. Make sure that `testing` is set in the `envs`-array in `very_basic_auth.php`.

Thank you
---------

[](#thank-you)

A big thank you to the people who has contributed to this package, among others:

**[kazuhei](https://github.com/kazuhei)** – for providing the awesome Japanese translation
**[freekmurze](https://github.com/freekmurze)** – for additional information on package/vendor installations
**[faiare](https://github.com/faiare)** – for pointing out and implementing the `realm`-attribute ([RFC7235](https://tools.ietf.org/html/rfc7235#section-2.2))

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

© 2024 [Marcus Olsson](https://marcusolsson.me).

###  Health Score

43

—

FairBetter than 89% of packages

Maintenance90

Actively maintained with recent releases

Popularity13

Limited adoption so far

Community16

Small or concentrated contributor base

Maturity47

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 85.7% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~0 days

Total

2

Last Release

46d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/60221974?v=4)[softinvest](/maintainers/softinvest)[@softinvest](https://github.com/softinvest)

---

Top Contributors

[![olssonm](https://avatars.githubusercontent.com/u/907114?v=4)](https://github.com/olssonm "olssonm (126 commits)")[![faiare](https://avatars.githubusercontent.com/u/11206952?v=4)](https://github.com/faiare "faiare (3 commits)")[![bugfix666](https://avatars.githubusercontent.com/u/151177991?v=4)](https://github.com/bugfix666 "bugfix666 (2 commits)")[![RowdyElectron](https://avatars.githubusercontent.com/u/4397586?v=4)](https://github.com/RowdyElectron "RowdyElectron (2 commits)")[![kazuhei](https://avatars.githubusercontent.com/u/3251744?v=4)](https://github.com/kazuhei "kazuhei (2 commits)")[![laravel-shift](https://avatars.githubusercontent.com/u/15991828?v=4)](https://github.com/laravel-shift "laravel-shift (2 commits)")[![rhynodesigns](https://avatars.githubusercontent.com/u/2198266?v=4)](https://github.com/rhynodesigns "rhynodesigns (1 commits)")[![sweptsquash](https://avatars.githubusercontent.com/u/9886472?v=4)](https://github.com/sweptsquash "sweptsquash (1 commits)")[![treyssatvincent](https://avatars.githubusercontent.com/u/18269685?v=4)](https://github.com/treyssatvincent "treyssatvincent (1 commits)")[![53ningen](https://avatars.githubusercontent.com/u/4178716?v=4)](https://github.com/53ningen "53ningen (1 commits)")[![umihico](https://avatars.githubusercontent.com/u/39179585?v=4)](https://github.com/umihico "umihico (1 commits)")[![amenk](https://avatars.githubusercontent.com/u/1087128?v=4)](https://github.com/amenk "amenk (1 commits)")[![andrii-trush](https://avatars.githubusercontent.com/u/14265776?v=4)](https://github.com/andrii-trush "andrii-trush (1 commits)")[![egs33](https://avatars.githubusercontent.com/u/9857221?v=4)](https://github.com/egs33 "egs33 (1 commits)")[![freekmurze](https://avatars.githubusercontent.com/u/483853?v=4)](https://github.com/freekmurze "freekmurze (1 commits)")[![msng](https://avatars.githubusercontent.com/u/29099?v=4)](https://github.com/msng "msng (1 commits)")

---

Tags

laravelAuthenticationhttp basic authbugfix666

###  Code Quality

TestsPest

Static AnalysisPHPStan

Code StylePHP\_CodeSniffer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/bugfix666-very-basic-auth/health.svg)

```
[![Health](https://phpackages.com/badges/bugfix666-very-basic-auth/health.svg)](https://phpackages.com/packages/bugfix666-very-basic-auth)
```

###  Alternatives

[php-open-source-saver/jwt-auth

JSON Web Token Authentication for Laravel and Lumen

84812.1M68](/packages/php-open-source-saver-jwt-auth)[directorytree/ldaprecord-laravel

LDAP Authentication &amp; Management for Laravel.

5752.6M24](/packages/directorytree-ldaprecord-laravel)[psalm/plugin-laravel

Psalm plugin for Laravel

3365.5M359](/packages/psalm-plugin-laravel)[olssonm/l5-very-basic-auth

Laravel stateless HTTP basic auth without the need for a database

1662.7M4](/packages/olssonm-l5-very-basic-auth)[hasinhayder/tyro

Tyro - The ultimate Authentication, Authorization, and Role &amp; Privilege Management solution for Laravel 12 &amp; 13

6796.8k8](/packages/hasinhayder-tyro)[alajusticia/laravel-logins

Session management in Laravel apps, user notifications on new access, support for multiple separate remember tokens, IP geolocation, User-Agent parser

2116.7k](/packages/alajusticia-laravel-logins)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
