Download the PHP package 3cplus/auth-middleware without Composer
On this page you can find all versions of the php package 3cplus/auth-middleware. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package auth-middleware
3CPlus Auth Middleware
A PHP middleware for authentication using API tokens, with Redis caching support.
Installation
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
- PHP 7.2 or higher
- Laravel/Illuminate Support
- GuzzleHTTP
- Predis
Environment Variables
The following environment variables are required:
Variable | Description |
---|---|
URL_APPLICATION_API |
URL of the authentication API endpoint |
REDIS_CACHE_HOST |
Redis server hostname |
REDIS_CACHE_PORT |
Redis server port |
Usage
Basic Implementation
Token Extraction
The middleware extracts the API token in the following order:
- From query parameter:
?api_token=your-token
- From Authorization header:
Authorization: Bearer your-token
Error Handling
The middleware throws exceptions with appropriate HTTP status codes:
401 Unauthorized
: When the API token is missing or invalid500 Internal Server Error
: For other processing errors
Caching
Successfully authenticated user data is cached in Redis for 1 hour (3600 seconds) to minimize API calls.
License
MIT
All versions of auth-middleware with dependencies
psr/container Version ^2.0
psr/http-message Version ^2.0
psr/http-server-middleware Version ^1.0
psr/http-server-handler Version ^1.0
psr/simple-cache Version ^3.0
guzzlehttp/guzzle Version ^7.0
guzzlehttp/psr7 Version ^2.0
ramsey/uuid Version ^4.0
illuminate/support Version ^10.48
predis/predis Version ^2.3
vlucas/phpdotenv Version ^5.6