acgranter/acgranter-symfony-authenticator
Illuminate\Auth, Laravel\Sanctum, or Laravel Passport). Direct integration would require significant abstraction layers or a custom bridge.spatie/laravel-permission, nWidart/laravel-roles-permissions) already provide similar functionality, reducing the need for this package unless specific Symfony-centric features (e.g., Symfony’s Voter system) are required.SecurityEvent), Laravel’s event system (Illuminate\Events) would need to be mapped, adding complexity.SecurityBundle and Authenticator interfaces (e.g., AbstractAuthenticator) are not natively compatible with Laravel’s Authenticatable, Guard, or UserProvider contracts.Authenticator logic into Laravel’s Auth system (e.g., custom Guard implementation).ServiceProvider to dynamically load Symfony components (risky due to dependency conflicts).security_acl_class_entry). Laravel’s permission packages use different tables (e.g., model_has_permissions, roles). Schema migration would be required, increasing risk.| Risk Area | Severity | Mitigation Strategy |
|---|---|---|
| Dependency Conflicts | High | Isolate Symfony dependencies in a separate module or use composer aliases. |
| Authentication Logic Gaps | High | Extend Laravel’s Authenticatable to support Symfony’s UserInterface. |
| Performance Overhead | Medium | Benchmark RBAC checks; consider caching (e.g., Redis) for permission lookups. |
| Maintenance Burden | High | Document custom integration heavily; plan for Symfony version updates. |
| Security Risks | Critical | Audit all translated security logic (e.g., Voter → Laravel middleware). |
Why Symfony-Specific?
Firewall, AccessControl) that Laravel alternatives lack?spatie/laravel-permission) be extended instead?Authentication Flow Compatibility
Authenticator interface conflicts arise with Laravel’s AuthenticatesUsers?RBAC Implementation
nwidart/laravel-roles-permissions.Testing Strategy
SecurityContext) translate to Laravel’s Auth tests?Long-Term Viability
HttpFoundation, SecurityBundle, and DependencyInjection components.replace or provide to fake Symfony dependencies, but this is fragile.laravel/symfony-bridge), integration is slightly easier but still non-trivial.Auth::attempt(), middleware, policies).Authenticator to Laravel’s Guard or AuthManager.Authenticator wrapper for a single route (e.g., /admin).UserProvider → Laravel’s EloquentUserProvider.spatie/laravel-permission + custom middleware (lowest risk).| Laravel Feature | Compatibility Risk | Workaround |
|---|---|---|
| Eloquent User Model | Medium | Implement Symfony\Component\Security\Core\User\UserInterface. |
| API Token Auth (Sanctum) | High | Extend TokenGuard to use Symfony’s Authenticator. |
| Middleware-Based Auth | Low | Convert Symfony Voter to Laravel middleware. |
| Caching (Redis) | Medium | Override Symfony’s cache adapter with Laravel’s. |
| Multi-Tenant Auth | High | Custom UserProvider per tenant. |
Auth::login() with a Symfony Authenticator-compatible method.ROLE_ADMIN).Acl/Voter to Laravel’s Gate or Policy.security_acl → permissions table).CsrfTokenManager vs. Laravel’s VerifyCsrfToken).spatie/laravel-permission.security-bundle may conflict with Laravel’s illuminate/auth. Solution: Use composer platform checks or a monorepo with strict dependency isolation.Authenticator failures.SecurityException) and Laravel (AuthenticationException). Tooling: Implement a custom error handler to normalize errors.Acl system may not scale well with high-traffic APIs. Alternatives:
spatie/laravel-permission (optimized for Laravel).SESSION_DRIVER=database).security_acl_class_entry) may grow with fine-grained permissions. Optimization:
How can I help you explore Laravel packages today?