PHPackages                             jalallinux/laravel-shield - 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. [HTTP &amp; Networking](/categories/http)
4. /
5. jalallinux/laravel-shield

ActiveLibrary[HTTP &amp; Networking](/categories/http)

jalallinux/laravel-shield
=========================

A HTTP basic auth middleware for Laravel

1.2.4(2y ago)01.9k[1 PRs](https://github.com/jalallinux/laravel-shield/pulls)MITPHPPHP ^8.0|^8.1|^8.2

Since Jan 6Pushed 1y ago1 watchersCompare

[ Source](https://github.com/jalallinux/laravel-shield)[ Packagist](https://packagist.org/packages/jalallinux/laravel-shield)[ Docs](https://github.com/jalallinux/laravel-shield)[ GitHub Sponsors](https://github.com/jalallinux)[ RSS](/packages/jalallinux-laravel-shield/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (7)Dependencies (3)Versions (9)Used By (0)

🔑 Laravel Shield
================

[](#-laravel-shield)

> A [HTTP basic auth](https://en.m.wikipedia.org/wiki/Basic_access_authentication) middleware for Laravel.

[![Latest Version on Packagist](https://camo.githubusercontent.com/b592a95052608ad73ece2ed52a32df18563be557e7c3e671ae96ec24c229c9bd/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6a616c616c6c696e75782f6c61726176656c2d736869656c642e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/jalallinux/laravel-shield)[![Tests](https://github.com/jalallinux/laravel-shield/actions/workflows/run-tests.yml/badge.svg?branch=main)](https://github.com/jalallinux/laravel-shield/actions/workflows/run-tests.yml)[![Total Downloads](https://camo.githubusercontent.com/d9d0701d67a3759d88ca24ae1a2956387ecefed45fd20d2f0f6650740eb57684/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6a616c616c6c696e75782f6c61726176656c2d736869656c642e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/jalallinux/laravel-shield)

```
// Use on your routes.
Route::get('/', ['middleware' => 'shield'], function () {
    // Your protected page.
});

// Use it within your controller constructor.
$this->middleware('shield');

// Use specific user credentials.
$this->middleware('shield:jalallinux');
```

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

[](#installation)

Require this package, with [Composer](https://getcomposer.org/), in the root directory of your project.

```
composer require jalallinux/laravel-shield
```

Add the middleware to the `$routeMiddleware` array in your `Kernel.php` file.

```
'shield' => \JalalLinuX\Shield\ShieldMiddleware::class,
```

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

[](#configuration)

Laravel Shield requires configuration. To get started, you'll need to publish all vendor assets:

```
php artisan vendor:publish --provider JalalLinuX\\Shield\\ShieldServiceProvider
```

This will create a `config/shield.php` file in your app that you can modify to set your configuration. Also, make sure you check for changes to the original config file in this package between releases.

#### HTTP Basic Auth Credentials

[](#http-basic-auth-credentials)

The user credentials which are used when logging in with [HTTP basic authentication](https://en.m.wikipedia.org/wiki/Basic_access_authentication).

Usage
-----

[](#usage)

To protect your routes with the shield you can add it to the routes file.

```
Route::get('/', ['middleware' => 'shield'], function () {
    // Your protected page.
});
```

You can also add the shield middleware to your controllers constructor.

```
$this->middleware('shield');
```

The middleware accepts one optional parameter to specify which user credentials to compared with.

```
$this->middleware('shield:jalallinux');
```

To add a new user, you probably want to use hashed credentials. Hashed credentials can be generated with the [`password_hash()`](https://secure.php.net/manual/en/function.password-hash.php) function in the terminal:

```
php -r "echo password_hash('my-secret-passphrase', PASSWORD_DEFAULT);"
```

Then copy and paste the hashed credentials to the `.env` environment file.

```
SHIELD_USER=your-hashed-user
SHIELD_PASSWORD=your-hashed-password
```

###  Health Score

32

—

LowBetter than 72% of packages

Maintenance27

Infrequent updates — may be unmaintained

Popularity15

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity63

Established project with proven stability

 Bus Factor1

Top contributor holds 65.9% 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 ~71 days

Recently: every ~6 days

Total

7

Last Release

800d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/ddef4e15a6bda9c060f6e33ccfd0a268895bfb664936f9191a836de4d528d684?d=identicon)[jalallinux](/maintainers/jalallinux)

---

Top Contributors

[![jalallinux](https://avatars.githubusercontent.com/u/37062636?v=4)](https://github.com/jalallinux "jalallinux (29 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (9 commits)")[![github-actions[bot]](https://avatars.githubusercontent.com/in/15368?v=4)](https://github.com/github-actions[bot] "github-actions[bot] (6 commits)")

---

Tags

httpmiddlewarelaravelauthbasicshieldlaravel-shieldjalallinux

###  Code Quality

TestsPest

### Embed Badge

![Health badge](/badges/jalallinux-laravel-shield/health.svg)

```
[![Health](https://phpackages.com/badges/jalallinux-laravel-shield/health.svg)](https://phpackages.com/packages/jalallinux-laravel-shield)
```

###  Alternatives

[matthewbdaly/laravel-etag-middleware

A Laravel middleware for adding ETags to HTTP requests to improve response times

64326.0k2](/packages/matthewbdaly-laravel-etag-middleware)[sven/super-basic-auth

A lightweight package to add basic authentication to your Laravel app.

232.6k](/packages/sven-super-basic-auth)[eljam/guzzle-jwt-middleware

A jwt authentication middleware for guzzle 6

28722.5k3](/packages/eljam-guzzle-jwt-middleware)[middlewares/http-authentication

Middleware to implement Basic and Digest Http authentication

35302.0k2](/packages/middlewares-http-authentication)[tomschlick/request-migrations

HTTP Request Migrations

1844.5k](/packages/tomschlick-request-migrations)[behamin/service-proxy

for proxy or sending requests to other services with useful utilities

102.2k](/packages/behamin-service-proxy)

PHPackages © 2026

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