symfony/security-core
Symfony Security Core provides the building blocks for authentication and authorization. Use tokens, voters, role hierarchies, and an access decision manager to cleanly separate access rules from user providers and credential storage.
AuthServiceProvider logic. It enables composable security policies (e.g., role + attribute + tenant voters) without coupling to Laravel’s built-in auth.spatie/laravel-permission or laravel/breeze handle basic RBAC, this package offers fine-grained control (e.g., AccessDecisionManager, VoteObject with extraData) for enterprise-grade ABAC or multi-tenant systems.Auth tokens (e.g., UsernamePasswordToken) but avoids Laravel’s session-binding, enabling stateless API auth (e.g., JWT + voters).ROLE_ADMIN → ROLE_USER) simplifies permission management in SaaS platforms with dynamic role structures.illuminate/pipeline.Authenticate middleware with a custom AccessDecisionManager-backed middleware.register()/boot() methods, injecting voters into the container.ServiceProvider or event listeners (e.g., Authorizing events).RememberMeDetails), which may require Laravel-specific wrappers for legacy systems.RoleHierarchy is optimized but may need Laravel cache integration (Redis/Memcached) for high-scale apps.TokenInterface requires strict mocking (fixed in v8.0.3), which may need Laravel-specific test utilities.symfony/console) could increase bundle size.Gate/Policy classes map to Voter interfaces?Auth in Symfony’s TokenStorage for gradual adoption?RoleHierarchy) conflict with Laravel’s cache drivers?eraseCredentials()) in Laravel’s auth system?symfony/http-foundation (if needed) for request/response objects, but avoid pulling in the full Symfony framework.Illuminate\Auth\Gate with a custom AccessDecisionManager middleware.AuthManager to yield Symfony tokens (e.g., UsernamePasswordToken).UserProvider to Symfony’s UserProviderInterface.RoleHierarchy.// Before (Laravel)
Gate::define('edit-post', function (User $user, Post $post) {
return $user->isAdmin();
});
// After (Symfony Voter)
$accessDecisionManager->decide($token, ['ROLE_ADMIN'], new PostVoter($post));
Authenticatable to implement Symfony\Component\Security\Core\User\UserInterface.Auth::user() with Symfony’s TokenStorage for consistent token access.RoleHierarchy and Voter system.Gate in favor of Symfony’s AccessDecisionManager.symfony/security-core alongside illuminate/auth via service binding.PersistentToken can integrate with Laravel’s session driver.Authenticate with a custom middleware using AccessDecisionManager.TokenInterface for API token validation.AuthenticationUtils for mocking tokens in tests.UserFactory to return Symfony\UserInterface objects.| Step | Task | Dependencies | Risk |
|---|---|---|---|
| 1 | Add symfony/security-core to composer.json |
None | Low |
| 2 | Create custom Voter classes for critical paths |
Laravel User model |
Medium |
| 3 | Replace Gate::define() with AccessDecisionManager middleware |
Step 2 | Medium |
| 4 | Extend Authenticatable to implement UserInterface |
Laravel Auth |
High |
| 5 | Migrate role/permission logic to RoleHierarchy |
Step 4 | High |
| 6 | Deprecate Gate in favor of Symfony voters |
Steps 1–5 | Medium |
spatie/laravel-symfony-security if available).SecurityBundle may complicate future Laravel-only features.How can I help you explore Laravel packages today?