tuupola/slim-basic-auth
Abandoned PSR-7/PSR-15 middleware providing HTTP Basic Authentication. Originally for Slim but works with any PSR-compatible framework (tested with Slim and Zend Expressive). Configure allowed username/password pairs and protect routes via middleware.
Illuminate\Http\Middleware) can integrate with PSR-15-compliant middleware with minimal abstraction.$router->group(['middleware' => 'auth.basic'], ...)), though Laravel lacks native PSR-15 support (requires psr/http-message facade or a bridge like league/psr7).auth:api (TokenGuard) or auth:basic (SessionGuard) may overlap, but this package offers fine-grained path/ignore rules and custom authenticators not natively available in Laravel’s auth system.Illuminate\Contracts\Http\Kernel or Illuminate\Http\Middleware) due to Laravel’s non-PSR-15 middleware contract.league/psr7 to bridge PSR-7 requests/responses to Laravel’s Symfony\Component\HttpFoundation\Request/Response.tuupola/slim-basic-auth via a PSR-7 adapter.psr/http-message, psr/http-server-middleware), but Laravel’s symfony/http-foundation may conflict with PSR-7 implementations. Resolvable via composer overrides or league/psr7.Authenticatable contracts but requires additional glue code.jimtools/basic-auth (recommended successor).secure: false (dangerous). Laravel’s HTTPS enforcement (e.g., App\Providers\AppServiceProvider::boot) should complement this.password_hash) or external storage (env files) are recommended.//api bypassing /api auth (fixed in v2.2.2). Test thoroughly in Laravel’s routing context.auth.basic vs. route middleware).csrf_exempt).auth:basic?
tuupola/slim-basic-auth or switch to jimtools/basic-auth immediately?secure setting?league/psr7 to convert Laravel’s Request/Response to PSR-7 objects.
use League\Psr7\Request as Psr7Request;
use League\Psr7\Response as Psr7Response;
use Tuupola\Middleware\HttpBasicAuthentication;
Illuminate\Foundation\Http\Middleware that:
Symfony\Component\HttpFoundation\Request to PSR-7.HttpBasicAuthentication.Response back to Laravel’s Response.app/Http/Kernel.php:
protected $routeMiddleware = [
'auth.basic' => \App\Http\Middleware\BasicAuthMiddleware::class,
];
Apply via routes:
Route::middleware(['auth.basic'])->group(function () {
Route::get('/admin', 'AdminController@index');
});
auth:basic for simple cases; only adopt this package if advanced features (e.g., before/after hooks) are needed.tuupola/slim-basic-auth to fix critical bugs (e.g., path matching) and add Laravel compatibility.composer require tuupola/slim-basic-auth@dev-main with a local fork.jimtools/basic-auth (PSR-15 compliant, actively maintained).AuthManager or Guard interfaces./api/admin).league/psr7 v1.x.auth.basic before route-specific middleware but after global middleware (e.g., TrimStrings, ConvertEmptyStringsToNull).csrf_exempt or VerifyCsrfToken@except.Authorization header is whitelisted.relaxed: ["localhost"] for local development.secure: true and remove relaxed except for trusted proxies (e.g., headers)..env or a secrets manager.error callback) to detect brute-force attacks.failed auth event listener for additional logging.jimtools/basic-auth.//api, /api/, /api//).error callback to log failed attempts with usernames.auth:api middleware isn’t also applied to the same routes.users array is fast but unscalable for large user bases. Use authenticator with a database (e.g., PdoAuthenticator) or Redis cache.PdoAuthenticator, ensure the database connection is reused (e.g., via Laravel’s DB facade) to avoid connection overhead.How can I help you explore Laravel packages today?