PHPackages                             3cplus/auth-middleware - 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. 3cplus/auth-middleware

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

3cplus/auth-middleware
======================

3C plus - api auth middleware

1.0.0(1y ago)015MITPHPPHP &gt;=8.0

Since Mar 18Pushed 1y ago2 watchersCompare

[ Source](https://github.com/3C-Plus/auth-middleware)[ Packagist](https://packagist.org/packages/3cplus/auth-middleware)[ RSS](/packages/3cplus-auth-middleware/feed)WikiDiscussions main Synced today

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

3CPlus Auth Middleware
======================

[](#3cplus-auth-middleware)

A PHP middleware for authentication using API tokens, with Redis caching support.

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

[](#installation)

```
composer require 3cplus/auth-middleware
```

Description
-----------

[](#description)

This middleware authenticates requests by validating API tokens against a remote authentication service. It supports token extraction from both query parameters and Authorization headers. For performance optimization, authenticated user data is cached in Redis.

Requirements
------------

[](#requirements)

- PHP 7.2 or higher
- Laravel/Illuminate Support
- GuzzleHTTP
- Predis

Environment Variables
---------------------

[](#environment-variables)

The following environment variables are **required**:

VariableDescription`URL_APPLICATION_API`URL of the authentication API endpoint`REDIS_CACHE_HOST`Redis server hostname`REDIS_CACHE_PORT`Redis server portUsage
-----

[](#usage)

### Basic Implementation

[](#basic-implementation)

```
use Dev3CPlus\Middleware\AuthMiddleware;

// Create middleware instance
$authMiddleware = new AuthMiddleware();

// Process the request
$response = $authMiddleware->process($request, $handler);
```

### Token Extraction

[](#token-extraction)

The middleware extracts the API token in the following order:

1. From query parameter: `?api_token=your-token`
2. From Authorization header: `Authorization: Bearer your-token`

### Error Handling

[](#error-handling)

The middleware throws exceptions with appropriate HTTP status codes:

- `401 Unauthorized`: When the API token is missing or invalid
- `500 Internal Server Error`: For other processing errors

### Caching

[](#caching)

Successfully authenticated user data is cached in Redis for 1 hour (3600 seconds) to minimize API calls.

License
-------

[](#license)

[MIT](LICENSE.md)

###  Health Score

26

—

LowBetter than 41% of packages

Maintenance42

Moderate activity, may be stable

Popularity6

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity43

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

Unknown

Total

1

Last Release

472d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/30061278?v=4)[Gabriel Krysa](/maintainers/gabrielkrysa)[@GabrielKrysa](https://github.com/GabrielKrysa)

---

Top Contributors

[![GabrielKrysa](https://avatars.githubusercontent.com/u/30061278?v=4)](https://github.com/GabrielKrysa "GabrielKrysa (8 commits)")

### Embed Badge

![Health badge](/badges/3cplus-auth-middleware/health.svg)

```
[![Health](https://phpackages.com/badges/3cplus-auth-middleware/health.svg)](https://phpackages.com/packages/3cplus-auth-middleware)
```

###  Alternatives

[laravel/framework

The Laravel Framework.

34.8k543.8M20.1k](/packages/laravel-framework)[aws/aws-sdk-php

AWS SDK for PHP - Use Amazon Web Services in your PHP project

6.3k543.5M2.6k](/packages/aws-aws-sdk-php)[tempest/framework

The PHP framework that gets out of your way.

2.2k34.4k15](/packages/tempest-framework)[typo3/cms

TYPO3 CMS is a free open source Content Management Framework initially created by Kasper Skaarhoj and licensed under GNU/GPL.

1.2k1.9M122](/packages/typo3-cms)[cakephp/cakephp

The CakePHP framework

8.9k19.5M1.8k](/packages/cakephp-cakephp)[moonshine/moonshine

Laravel administration panel

1.3k253.1k81](/packages/moonshine-moonshine)

PHPackages © 2026

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