symfony/security-acl
's direct dependencies. Data on all dependencies, including transitive ones, is available via CSV download.Name | Version | Size | License | Type | Vulnerabilities |
---|---|---|---|---|---|
symfony/security-core | v7.0.7 | - | MIT | prod dev |
The Symfony Security Component - ACL (Access Control List), also known as symfony/security-acl, provides infrastructure for complex authorization systems. This powerful tool makes it possible to easily segregate the actual authorization logic, empowering you to control access to resources based on a user's privileges in a highly sophisticated way. The component finds its inspiration in the Java Spring framework, ensuring it can handle robust security requirements.
To use the symfony/security-acl, you begin by installing the component. It can be added to your project using the composer. Navigate to your project root in your command-line interface and run this command:
composer require symfony/security-acl
After the package has been installed, you can use it in your PHP code. The following is just a simple demonstration:
use Symfony\Component\Security\Acl\Permission\MaskBuilder;
use Symfony\Component\Security\Acl\Domain\UserSecurityIdentity;
use Symfony\Component\Security\Acl\Domain\ObjectIdentity;
// creating the ACL
$aclProvider = $this->get('security.acl.provider');
$objectIdentity = ObjectIdentity::fromDomainObject($domainObject);
$acl = $aclProvider->createAcl($objectIdentity);
// retrieving the security identity of the currently logged-in user
$securityIdentity = UserSecurityIdentity::fromAccount($user);
// grant owner access
$acl->insertObjectAce($securityIdentity, MaskBuilder::MASK_OWNER);
$aclProvider->updateAcl($acl);
Please note that you need to replace $this->get('security.acl.provider')
and $user
with your own actual service container and user object.
The comprehensive documentation for the symfony/security-acl component is available at the following location. This online guide provides a more in-depth look at how to utilize this flexible and robust security component effectively: