PHPackages                             weldon/env-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. weldon/env-auth

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

weldon/env-auth
===============

The package provides middleware for Laravel applications to handle Basic Authentication and Secret Key Authentication using credentials stored in the .env file.

v1.0.0(1y ago)0184MITPHPPHP ^7.4|^8.0

Since Feb 21Pushed 1y agoCompare

[ Source](https://github.com/weldon-tech/env-auth)[ Packagist](https://packagist.org/packages/weldon/env-auth)[ Docs](https://github.com/weldon-tech/env-auth)[ RSS](/packages/weldon-env-auth/feed)WikiDiscussions main Synced 1mo ago

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

weldon/env-auth
===============

[](#weldonenv-auth)

[![Packagist Dependency Version](https://camo.githubusercontent.com/551467035882080357dd100a46f60aa820def39df6f3775a0c53221bca82a490/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f646570656e64656e63792d762f77656c646f6e2f656e762d617574682f706870)](https://camo.githubusercontent.com/551467035882080357dd100a46f60aa820def39df6f3775a0c53221bca82a490/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f646570656e64656e63792d762f77656c646f6e2f656e762d617574682f706870)[![Total Downloads](https://camo.githubusercontent.com/b920e25ca1598f0f05ce370c8bcfab2f53cca87d265295961b06fcedf52830c9/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f77656c646f6e2f656e762d617574682e737667)](https://camo.githubusercontent.com/b920e25ca1598f0f05ce370c8bcfab2f53cca87d265295961b06fcedf52830c9/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f77656c646f6e2f656e762d617574682e737667)[![Latest Version on Packagist](https://camo.githubusercontent.com/fb4278f64010338b461ad9598540de36cb1f5d7ffd008a262dd7ae722655882e/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f77656c646f6e2f656e762d617574682e737667)](https://camo.githubusercontent.com/fb4278f64010338b461ad9598540de36cb1f5d7ffd008a262dd7ae722655882e/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f77656c646f6e2f656e762d617574682e737667)[![Packagist License](https://camo.githubusercontent.com/5add81e99e5239266d48e36f0e40a2222309b5cee227267437724ba223574c7d/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f77656c646f6e2f656e762d61757468)](https://camo.githubusercontent.com/5add81e99e5239266d48e36f0e40a2222309b5cee227267437724ba223574c7d/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f77656c646f6e2f656e762d61757468)

The package provides middleware for Laravel applications to handle Basic Authentication and Secret Key Authentication using credentials stored in the `.env` file.

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

[](#installation)

You can install the package via composer:

```
composer require weldon/env-auth
```

Publish
-------

[](#publish)

Publish the package configuration:

```
php artisan vendor:publish --provider="Weldon\EnvAuth\EnvAuthServiceProvider"
```

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

[](#configuration)

Add the necessary credentials to your `.env` file.

If you want to modify keys of variables, you need to change `config/env-auth.php` after publish config file.

For `BasicEnv` middleware:

```
BASIC_USERNAME=your-username
BASIC_PASSWORD=your-password
```

For `SecretEnv` middleware:

```
AUTH_SECRET_KEY=your-secret-key
```

Usage
-----

[](#usage)

### Register middleware

[](#register-middleware)

If you are using Laravel 11.x check out this link:

In your Laravel application's `app/Http/Kernel.php` file, register the new middleware classes:

```
protected $routeMiddleware = [
    // Other middleware
    'basic.env' => \Weldon\EnvAuth\Middleware\BasicEnv::class,
    'secret.env' => \Weldon\EnvAuth\Middleware\SecretEnv::class,
];
```

### Protect routes

[](#protect-routes)

Apply the middleware to your routes in `routes/web.php` or `routes/api.php`.

```
Route::middleware('basic.env')->group(function () {

    ...
});
```

Testing
-------

[](#testing)

Use the following cURL command to test Basic Authentication:

```
curl -u your-username:your-password http://your-app-url/basic-protected-route
```

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

License
-------

[](#license)

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

###  Health Score

28

—

LowBetter than 54% of packages

Maintenance43

Moderate activity, may be stable

Popularity10

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity42

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 91.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

Unknown

Total

1

Last Release

451d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/f3287e990c6a21e337bdb915cd5547c35a4a5dfad1322bc639479ffaaaa41765?d=identicon)[weldon-tech](/maintainers/weldon-tech)

---

Top Contributors

[![usmonaliyev99](https://avatars.githubusercontent.com/u/63544323?v=4)](https://github.com/usmonaliyev99 "usmonaliyev99 (11 commits)")[![asrorbek-mannonov](https://avatars.githubusercontent.com/u/44311347?v=4)](https://github.com/asrorbek-mannonov "asrorbek-mannonov (1 commits)")

---

Tags

configweldon

###  Code Quality

TestsPHPUnit

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/weldon-env-auth/health.svg)

```
[![Health](https://phpackages.com/badges/weldon-env-auth/health.svg)](https://phpackages.com/packages/weldon-env-auth)
```

###  Alternatives

[bezhansalleh/filament-shield

Filament support for `spatie/laravel-permission`.

2.8k2.9M88](/packages/bezhansalleh-filament-shield)[illuminate/auth

The Illuminate Auth package.

9327.3M1.0k](/packages/illuminate-auth)[olssonm/l5-very-basic-auth

Laravel stateless HTTP basic auth without the need for a database

1662.5M1](/packages/olssonm-l5-very-basic-auth)[scaler-tech/laravel-saml2

SAML2 Service Provider integration for Laravel applications, based on OneLogin toolkit

2737.5k](/packages/scaler-tech-laravel-saml2)[truckersmp/steam-socialite

Laravel Socialite provider for Steam OpenID.

1516.7k](/packages/truckersmp-steam-socialite)[pschocke/laravel-telegram-login-widget

Easily integrate Telegrams login widget into your Laravel application to send Telegram messages

1610.4k](/packages/pschocke-laravel-telegram-login-widget)

PHPackages © 2026

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