symfony/security-http
Symfony Security HTTP integrates the Security Core with HTTP: firewalls, request handling, and authenticators to secure parts of your app and authenticate users. Install via composer require symfony/security-http.
#[IsGranted], #[CurrentUser]) enables cleaner route/controller annotations, replacing Laravel’s can() or middleware clutter.Illuminate\Http (shared request/response structures).Firewall listeners via custom middleware (e.g., SymfonyFirewallMiddleware).Authenticatable contracts with minimal glue code (e.g., AbstractAuthenticator → Laravel’s Authenticator interface).VerifyCsrfToken middleware, though Symfony’s #[IsCsrfTokenValid] offers finer-grained control.RememberMeDetails FQCN, removal of callable firewalls) may require Laravel-specific wrappers.HttpClient for OIDC), but can be scoped to only needed components.SecurityEventDispatcher) may require mocking adjustments in Laravel’s PHPUnit tests.FirewallMap translate to Laravel’s middleware groups?RouteMiddleware or a custom FirewallMiddleware?User model extend Symfony’s UserInterface without conflicts?UserProvider integrate with Laravel’s AuthManager?security:oidc-token:generate CLI, or can Laravel’s Socialite suffice?RememberMeDetails) in a Laravel 10+ project?HttpFoundation, HttpClient, and OptionsResolver.Illuminate/Auth middleware with Symfony’s Firewall listeners.AuthenticatorInterface alongside Laravel’s Authenticatable for hybrid auth.SecurityBundle for features like impersonation, voter systems, and OIDC.security:check CLI can complement Laravel’s php artisan auth:check.security:debug:firewall to visualize firewall routes.OidcAuthenticator.VerifyCsrfToken with Symfony’s CsrfTokenManager (attribute-based).Policy classes to Symfony’s VoterInterface.SymfonyFirewallMiddleware to wrap FirewallMap.Guard to use Symfony’s AuthenticatorManager.UserProvider to implement Symfony’s UserProviderInterface.AuthMiddleware with Symfony’s FirewallListener.SecurityContext.#[IsGranted] attributes.symfony/security-http:^8.0 with Laravel’s Symfony bridge packages.config.php and extensions (e.g., ext-openssl) are updated.ContainerBuilder can coexist with Laravel’s Container via a custom ServiceProvider.SecurityEventDispatcher can integrate with Laravel’s Events via a bridge (e.g., dispatch Symfony events to Laravel listeners).| Step | Action | Dependencies | Risk |
|---|---|---|---|
| 1. Setup | Add symfony/security-http to composer.json. |
PHP 8.4+, Laravel 10+ | Low |
| 2. Pilot | Implement OIDC authenticator. | Symfony’s HttpClient |
Medium (OIDC config complexity) |
| 3. Middleware Bridge | Create SymfonyFirewallMiddleware to wrap FirewallMap. |
Laravel’s middleware stack | High (integration effort) |
| 4. Auth Adapter | Build SymfonyAuthGuard to bridge AuthenticatorManager and Laravel. |
User provider compatibility | Medium |
| 5. CSRF Migration | Replace VerifyCsrfToken with Symfony’s CsrfTokenManager. |
Session/cookie storage | Low |
| 6. Testing | Validate auth flows with Symfony’s SecurityContext. |
Test doubles for FirewallListener |
High (test suite updates) |
| 7. Deprecation Cleanup | Remove Laravel-specific auth logic (e.g., AuthenticatesUsers). |
Feature parity with Symfony | Medium (refactoring) |
#[IsGranted]) replace repetitive middleware.config/packages/security.yaml (or Laravel’s config/auth.php).SecurityEvent) adds layers to trace.Firewall, Authenticator, and Voter concepts.Guard/Policy and Symfony’s equivalents.SecurityContext can cache user/auth data; integrate with Laravel’s cache (Illuminate/Cache).HttpClient for OIDC.PersistentToken (for "remember me") can use Laravel’s database; ensure schema compatibility.| Scenario | Symfony Impact | Mitigation |
|---|---|---|
| Firewall misconfiguration | 403 errors for all routes. | Use security:debug:firewall to validate rules. |
| OIDC provider downtime | Auth failures for OIDC users. | Fallback to form login or cache tokens. |
| Session store corruption | User logout or invalid sessions |
How can I help you explore Laravel packages today?