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

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

usmonaliyev/env-auth
====================

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

1.1.0(1y ago)42531MITPHPPHP ^7.4|^8.0

Since Jun 3Pushed 1y ago1 watchersCompare

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

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

usmonaliyev/env-auth
====================

[](#usmonaliyevenv-auth)

[![Packagist Dependency Version](https://camo.githubusercontent.com/a88bbeb033c7f30e8f1ede615445e11bb40c7451b14d57a3c0567dfdd36983fb/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f646570656e64656e63792d762f75736d6f6e616c697965762f656e762d617574682f706870)](https://camo.githubusercontent.com/a88bbeb033c7f30e8f1ede615445e11bb40c7451b14d57a3c0567dfdd36983fb/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f646570656e64656e63792d762f75736d6f6e616c697965762f656e762d617574682f706870)[![Total Downloads](https://camo.githubusercontent.com/e3af87217eae1589003083b19a55f1587b7e0985068220daec64f688b3760903/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f75736d6f6e616c697965762f656e762d617574682e737667)](https://camo.githubusercontent.com/e3af87217eae1589003083b19a55f1587b7e0985068220daec64f688b3760903/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f75736d6f6e616c697965762f656e762d617574682e737667)[![Latest Version on Packagist](https://camo.githubusercontent.com/8fb95b76dfa15444d0dfcf0a0a50b752b5dadd89e95c1d2266c75b750de0b46e/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f75736d6f6e616c697965762f656e762d617574682e737667)](https://camo.githubusercontent.com/8fb95b76dfa15444d0dfcf0a0a50b752b5dadd89e95c1d2266c75b750de0b46e/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f75736d6f6e616c697965762f656e762d617574682e737667)[![Packagist License](https://camo.githubusercontent.com/aacc0dabb16f2e7542bbee9e8394a6f26a239a290e5c43192612bc8954787ce9/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f75736d6f6e616c697965762f656e762d61757468)](https://camo.githubusercontent.com/aacc0dabb16f2e7542bbee9e8394a6f26a239a290e5c43192612bc8954787ce9/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f75736d6f6e616c697965762f656e762d61757468)

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 usmonaliyev/env-auth
```

Publish
-------

[](#publish)

Publish the package configuration:

```
php artisan vendor:publish --provider="Usmonaliyev\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' => \Usmonaliyev\EnvAuth\Middleware\BasicEnv::class,
    'secret.env' => \Usmonaliyev\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

Maintenance33

Infrequent updates — may be unmaintained

Popularity16

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity46

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% 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 ~20 days

Total

2

Last Release

691d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/62ad097b3a2c1c7fba629ae280b33a9bcb12caf5dab6846737a7703046c5bad4?d=identicon)[usmonaliyev99](/maintainers/usmonaliyev99)

---

Top Contributors

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

---

Tags

configusmonaliyev

###  Code Quality

TestsPHPUnit

Code StyleLaravel Pint

### Embed Badge

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

```
[![Health](https://phpackages.com/badges/usmonaliyev-env-auth/health.svg)](https://phpackages.com/packages/usmonaliyev-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)
