Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message
Slim Basic Auth

Slim Basic Auth Laravel Package

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.

View on GitHub
Deep Wiki
Context7

PSR-7 and PSR-15 HTTP Basic Authentication Middleware

Frequently asked questions about Slim Basic Auth
Can I use tuupola/slim-basic-auth directly in Laravel without extra work?
No, this package requires PSR-7/PSR-15 compatibility, which Laravel doesn’t natively support. You’ll need to wrap it in a Laravel middleware class using a PSR-7 bridge like `league/psr7` to convert Laravel’s `Request`/`Response` objects.
How do I integrate this middleware into Laravel’s route groups?
Create a Laravel middleware class that delegates to `tuupola/slim-basic-auth`, then register it in `app/Http/Kernel.php` under `$routeMiddleware`. Apply it via `Route::middleware(['auth.basic'])->group(...)` or `->middleware('auth.basic')` on individual routes.
Is this package compatible with Laravel’s built-in auth:basic?
No, this package is PSR-15 middleware, while Laravel’s `auth:basic` uses session-based auth. This package offers finer-grained path/ignore rules and custom authenticators, but requires manual setup.
What’s the recommended way to store credentials securely?
Avoid plaintext passwords. Use environment variables (`.env`) or a database with hashed passwords (via `password_hash`). For production, consider Hashicorp Vault or Laravel’s `Hash` facade for secure storage.
Does this middleware enforce HTTPS by default?
No, it respects the `secure` config option (defaults to `true`). Ensure Laravel’s `AppServiceProvider` enforces HTTPS redirects to prevent HTTP Basic Auth over insecure connections.
How do I handle path/ignore rules for partial route protection?
Configure the `ignore` option in the middleware’s `users` array (e.g., `ignore: ['/public/*']`). Test thoroughly in Laravel’s routing context, as path matching may differ from Slim/Zend Expressive.
What’s the best alternative to this abandoned package?
The README recommends `jimtools/basic-auth`, which is actively maintained and offers similar PSR-7/PSR-15 middleware functionality. It’s a drop-in replacement with better long-term support.
Will this work with Laravel’s API resources (e.g., Sanctum or Passport)?
Yes, but ensure API routes are `csrf_exempt` since Basic Auth bypasses CSRF protection. Combine with Laravel’s `auth:sanctum` or `auth:api` for token-based auth where needed.
How do I test this middleware in Laravel’s testing environment?
Mock the PSR-7 bridge and middleware wrapper in PHPUnit tests. Use Laravel’s `actingAs()` helper for session-based auth tests, but for this package, simulate Basic Auth headers in HTTP requests (e.g., `Authorization: Basic base64`).
What Laravel versions does this package support?
The package itself doesn’t enforce Laravel versions, but you’ll need Laravel 5.5+ for PSR-7 bridges like `league/psr7`. Test compatibility with your Laravel version, as middleware injection timing may vary.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
terminal42/code-quality-tools
codifyo/ts-generator-bundle
andydefer/laravel-cluster
testo/fiber
mintobit/jobqueue
a4sex/maintenance-bundle
a4sex/entity-date-update
a4sex/client-identifier
a4sex/base-utilites
a4sex/key-value-storage
a4sex/micro-status
chilldev/dependency-injection-extra
datinglibre/datinglibre-app-api
biberltd/corebundle
bricre/symfony-bundle-test
biberltd/logbundle
dominium/http-adapter-bundle
dominium/google-analytics
a4sex/auto-clean-entity
christhompsontldr/laravel-inky