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 1mo ago

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

27

—

LowBetter than 49% of packages

Maintenance45

Moderate activity, may be stable

Popularity6

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity42

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

427d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/a91a8e0db6e4c1074b727e8e880bb0e26f5ce0889b03a40c4f1e97786ffb4b3e?d=identicon)[gabrielkrysa](/maintainers/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.7k509.9M17.0k](/packages/laravel-framework)[cakephp/cakephp

The CakePHP framework

8.8k18.5M1.6k](/packages/cakephp-cakephp)[shopware/platform

The Shopware e-commerce core

3.3k1.5M3](/packages/shopware-platform)[neos/flow-development-collection

Flow packages in a joined repository for pull requests.

144179.3k3](/packages/neos-flow-development-collection)[thecodingmachine/graphqlite

Write your GraphQL queries in simple to write controllers (using webonyx/graphql-php).

5723.1M30](/packages/thecodingmachine-graphqlite)[neos/flow

Flow Application Framework

862.0M451](/packages/neos-flow)

PHPackages © 2026

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