Weave 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

Http Basic Authenticator Bundle Laravel Package

symfony-notes/http-basic-authenticator-bundle

A Symfony bundle that adds HTTP Basic authentication support through a dedicated authenticator, making it simple to protect routes and APIs with username and password credentials in your Symfony applications.

View on GitHub
Deep Wiki
Context7

Getting Started

This is a Symfony bundle, not a Laravel package — the first step for a Laravel developer is translating the concept rather than expecting composer require to slot into config/app.php. HTTP Basic auth is the same protocol either way: the client sends Authorization: Basic base64(user:pass) on every request, and the server validates it per-request with no session.

Minimal steps:

  1. Install: composer require symfony-notes/http-basic-authenticator-bundle. Because the package has no stars or dependents, read the source in vendor/ before trusting it — check the composer.json for supported Symfony/PHP versions and confirm the authenticator class actually implements AuthenticatorInterface.
  2. Register the bundle in config/bundles.php (Symfony Flex usually does this automatically; without a Flex recipe you must add it manually).
  3. Wire it into the firewall in config/packages/security.yaml — either via the built-in http_basic: provider or by referencing the bundle's authenticator under guard/custom_authenticators depending on the Symfony version it targets.
  4. First use case: protect a stateless API or an internal admin endpoint. Set stateless: true on the firewall and test with curl -u user:pass https://localhost/api/ping.

If you are actually on Laravel, the equivalent first use case is Route::middleware('auth.basic') or Auth::onceBasic() in a middleware — use this bundle only if you are maintaining a Symfony service or building something Symfony-compatible.

Implementation Patterns

Stateless firewall for APIs. The canonical pattern is a dedicated firewall with stateless: true, http_basic (or the bundle's authenticator), and a provider pointing at an in-memory, entity, or custom user provider. No session, no CSRF, no login form — every request carries credentials.

Custom user provider. For token-style credentials or API keys masquerading as passwords, implement UserProviderInterface (or PasswordAuthenticator in newer Symfony) so the bundle's authenticator can resolve a UserInterface from the supplied username. Keep the provider side-effect free and cache-friendly.

Multiple firewalls / route matching. Scope Basic auth to a pattern (e.g. ^/api) so browser-facing routes keep their form login. Order matters: first matching firewall wins, so put the specific pattern above the catch-all main.

Layered on top of another mechanism. A common workflow is Basic auth as a bootstrap/impersonation layer behind an internal network, with a JWT or session authenticator handling the real user flow. Combine by making the Basic authenticator return a populated user and letting the stateless firewall short-circuit on success.

Testing workflow. Use curl -u user:pass, or in PHPUnit set a PHP_AUTH_USER/PHP_AUTH_PW server pair on the request. Assert on 401 with a WWW-Authenticate header for the failure path and 200 plus expected payload for success. Add a test for wrong password and for missing header separately.

Integration tip. Because the credentials are sent on every request, terminate TLS at the edge and configure your reverse proxy to forward the Authorization header (some proxies strip it by default). Document this in the service's README.

Gotchas and Tips

  • Basic auth is base64, not encryption. Over plain HTTP the credentials are trivially recoverable. Enforce HTTPS at the web server, not just in application config.
  • WWW-Authenticate drives browser behavior. If the header is missing on 401, browsers won't prompt and API clients can't negotiate. The realm value is cosmetic but should be stable.
  • Sessions leak. Forgetting stateless: true means Symfony starts a session and sets a cookie, silently changing the security model. Verify with Set-Cookie absent in responses.
  • Password hashing mismatch. Basic auth still runs through the password encoder. Plaintext passwords in an in-memory provider need plaintext; storing hashed passwords requires the matching encoder (auto, bcrypt, argon2id). A mismatch yields confusing 401s with no error detail.
  • Credential caching by clients. Browsers and HTTP clients cache Basic credentials aggressively and may retry them against other paths on the same host. Scope the firewall pattern tightly to avoid credentials being replayed against admin routes.
  • Symfony version drift. Authenticator APIs changed between Symfony 5.3+ (AuthenticatorInterface), 6.x, and 7.x. With zero dependents there is no compatibility signal — check the package's composer.json constraints against your Symfony version before committing.
  • Password in URL is not supported. https://user:pass@host is deprecated in many clients; test with explicit headers.
  • Debugging. Enable the Symfony profiler and inspect the Security panel; it shows which authenticator ran and why it failed. bin/console debug:config security confirms the firewall actually picked up the bundle's authenticator.
  • Extension points. The bundle likely exposes a service ID for the authenticator — override it in services.yaml to inject a custom user provider or logger. If it hardcodes a listener, prefer decorating the service rather than forking while the package is unmaintained.
  • Supply-chain caution. No stars, no dependents, no release history. Pin an exact version, review the diff on every update, and prefer a first-party Symfony http_basic firewall unless the bundle adds something you specifically need (e.g. custom challenge headers or per-route realms).
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.
skyraptor/chatter
edlugz/sasapay
abbasudo/artisan-route
mirvan/ippanel
ignibyte/aic-framework
glavweb/data-schema-bundle
glavweb/datagrid-bundle
tacticmedia/scim-server
uni-method/frame
neika-ai/sdk
adachsoft/php-code-style
pharaonic/laravel-notification-dependencies
beautinow/translug
dev-brainiac/bot-cloaked
octoberrain/html
octoberrain/extension
octoberrain/exception
octoberrain/contracts
adachsoft/api-version-bundle
cgv/localized-resource