symfony/security-acl
Symfony Security ACL adds Access Control Lists to manage fine‑grained, object‑level permissions beyond roles. It supports per‑object and per‑field authorization with configurable permission masks and voters, integrating with Symfony’s security system.
Start by installing the package via Composer (composer require symfony/security-acl) and enabling it in your kernel (via SecurityBundle in Symfony 5.4+, or manually in older versions). The first real-world use case is securing domain objects—e.g., enforcing that only the author of a BlogPost can edit it. Define ACLs programmatically using AclProviderInterface and ObjectIdentity, or integrate with Doctrine via the symfony/security-acl-bundle (if available for your Symfony version). Your first test: grant a user MASK_EDIT on one specific post—and verify they cannot edit others.
PostPermissionService) rather than controllers—keep authorization logic close to the entity.App\Entity\Post) to define default permissions (e.g., ROLE_EDITOR can edit all posts), then optionally override with object-specific ACEs.AclVoter) and call $this->is_granted('EDIT', $post) in controllers/services instead of manually interacting with AclInterface.AclProviderInterface::getAcl() with caching (via Symfony’s cache component) to avoid repeated DB hits—implement a custom AclProvider if needed.MASK_VIEW, MASK_COMMENT, MASK_DELETE) using bitwise OR/AND in your voter logic.DEBUG_ACL=true and use query caching. Avoid per-object ACLs for high-volume data (e.g., millions of posts); prefer class-level ACLs + ownership flags.owner field on your entity and wire it to UserSecurityIdentity manually in your ACL setup.AclEntryNotFoundException due to uncommitted ACL tables.cache:clear --env=prod) after ACL changes—symfony/security-acl relies heavily on in-memory caching unless configured otherwise.How can I help you explore Laravel packages today?