This commit is contained in:
Xes
2025-08-14 22:41:49 +02:00
parent 2de81ccc46
commit 8ce45119b6
39774 changed files with 4309466 additions and 0 deletions

View File

@@ -0,0 +1,66 @@
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Security\Acl\Model;
/**
* AclCache Interface.
*
* @author Johannes M. Schmitt <schmittjoh@gmail.com>
*/
interface AclCacheInterface
{
/**
* Removes an ACL from the cache.
*
* @param string $primaryKey a serialized primary key
*/
public function evictFromCacheById($primaryKey);
/**
* Removes an ACL from the cache.
*
* The ACL which is returned, must reference the passed object identity.
*
* @param ObjectIdentityInterface $oid
*/
public function evictFromCacheByIdentity(ObjectIdentityInterface $oid);
/**
* Retrieves an ACL for the given object identity primary key from the cache.
*
* @param int $primaryKey
*
* @return AclInterface
*/
public function getFromCacheById($primaryKey);
/**
* Retrieves an ACL for the given object identity from the cache.
*
* @param ObjectIdentityInterface $oid
*
* @return AclInterface
*/
public function getFromCacheByIdentity(ObjectIdentityInterface $oid);
/**
* Stores a new ACL in the cache.
*
* @param AclInterface $acl
*/
public function putInCache(AclInterface $acl);
/**
* Removes all ACLs from the cache.
*/
public function clearCache();
}

View File

@@ -0,0 +1,114 @@
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Security\Acl\Model;
use Symfony\Component\Security\Acl\Exception\NoAceFoundException;
/**
* This interface represents an access control list (ACL) for a domain object.
* Each domain object can have exactly one associated ACL.
*
* An ACL contains all access control entries (ACE) for a given domain object.
* In order to avoid needing references to the domain object itself, implementations
* use ObjectIdentity implementations as an additional level of indirection.
*
* @author Johannes M. Schmitt <schmittjoh@gmail.com>
*/
interface AclInterface extends \Serializable
{
/**
* Returns all class-based ACEs associated with this ACL.
*
* @return array
*/
public function getClassAces();
/**
* Returns all class-field-based ACEs associated with this ACL.
*
* @param string $field
*
* @return array
*/
public function getClassFieldAces($field);
/**
* Returns all object-based ACEs associated with this ACL.
*
* @return array
*/
public function getObjectAces();
/**
* Returns all object-field-based ACEs associated with this ACL.
*
* @param string $field
*
* @return array
*/
public function getObjectFieldAces($field);
/**
* Returns the object identity associated with this ACL.
*
* @return ObjectIdentityInterface
*/
public function getObjectIdentity();
/**
* Returns the parent ACL, or null if there is none.
*
* @return AclInterface|null
*/
public function getParentAcl();
/**
* Whether this ACL is inheriting ACEs from a parent ACL.
*
* @return bool
*/
public function isEntriesInheriting();
/**
* Determines whether field access is granted.
*
* @param string $field
* @param array $masks
* @param array $securityIdentities
* @param bool $administrativeMode
*
* @return bool
*/
public function isFieldGranted($field, array $masks, array $securityIdentities, $administrativeMode = false);
/**
* Determines whether access is granted.
*
* @param array $masks
* @param array $securityIdentities
* @param bool $administrativeMode
*
* @throws NoAceFoundException when no ACE was applicable for this request
*
* @return bool
*/
public function isGranted(array $masks, array $securityIdentities, $administrativeMode = false);
/**
* Whether the ACL has loaded ACEs for all of the passed security identities.
*
* @param mixed $securityIdentities an implementation of SecurityIdentityInterface, or an array thereof
*
* @return bool
*/
public function isSidLoaded($securityIdentities);
}

View File

@@ -0,0 +1,56 @@
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Security\Acl\Model;
use Symfony\Component\Security\Acl\Exception\AclNotFoundException;
/**
* Provides a common interface for retrieving ACLs.
*
* @author Johannes M. Schmitt <schmittjoh@gmail.com>
*/
interface AclProviderInterface
{
/**
* Retrieves all child object identities from the database.
*
* @param ObjectIdentityInterface $parentOid
* @param bool $directChildrenOnly
*
* @return array returns an array of child 'ObjectIdentity's
*/
public function findChildren(ObjectIdentityInterface $parentOid, $directChildrenOnly = false);
/**
* Returns the ACL that belongs to the given object identity.
*
* @param ObjectIdentityInterface $oid
* @param SecurityIdentityInterface[] $sids
*
* @return AclInterface
*
* @throws AclNotFoundException when there is no ACL
*/
public function findAcl(ObjectIdentityInterface $oid, array $sids = array());
/**
* Returns the ACLs that belong to the given object identities.
*
* @param ObjectIdentityInterface[] $oids an array of ObjectIdentityInterface implementations
* @param SecurityIdentityInterface[] $sids an array of SecurityIdentityInterface implementations
*
* @return \SplObjectStorage mapping the passed object identities to ACLs
*
* @throws AclNotFoundException when we cannot find an ACL for all identities
*/
public function findAcls(array $oids, array $sids = array());
}

View File

@@ -0,0 +1,29 @@
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Security\Acl\Model;
/**
* Interface for audit loggers.
*
* @author Johannes M. Schmitt <schmittjoh@gmail.com>
*/
interface AuditLoggerInterface
{
/**
* This method is called whenever access is granted, or denied, and
* administrative mode is turned off.
*
* @param bool $granted
* @param EntryInterface $ace
*/
public function logIfNeeded($granted, EntryInterface $ace);
}

View File

@@ -0,0 +1,58 @@
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Security\Acl\Model;
/**
* This interface adds auditing capabilities to the ACL.
*
* @author Johannes M. Schmitt <schmittjoh@gmail.com>
*/
interface AuditableAclInterface extends MutableAclInterface
{
/**
* Updates auditing for class-based ACE.
*
* @param int $index
* @param bool $auditSuccess
* @param bool $auditFailure
*/
public function updateClassAuditing($index, $auditSuccess, $auditFailure);
/**
* Updates auditing for class-field-based ACE.
*
* @param int $index
* @param string $field
* @param bool $auditSuccess
* @param bool $auditFailure
*/
public function updateClassFieldAuditing($index, $field, $auditSuccess, $auditFailure);
/**
* Updates auditing for object-based ACE.
*
* @param int $index
* @param bool $auditSuccess
* @param bool $auditFailure
*/
public function updateObjectAuditing($index, $auditSuccess, $auditFailure);
/**
* Updates auditing for object-field-based ACE.
*
* @param int $index
* @param string $field
* @param bool $auditSuccess
* @param bool $auditFailure
*/
public function updateObjectFieldAuditing($index, $field, $auditSuccess, $auditFailure);
}

View File

@@ -0,0 +1,34 @@
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Security\Acl\Model;
/**
* ACEs can implement this interface if they support auditing capabilities.
*
* @author Johannes M. Schmitt <schmittjoh@gmail.com>
*/
interface AuditableEntryInterface extends EntryInterface
{
/**
* Whether auditing for successful grants is turned on.
*
* @return bool
*/
public function isAuditFailure();
/**
* Whether auditing for successful denies is turned on.
*
* @return bool
*/
public function isAuditSuccess();
}

View File

@@ -0,0 +1,29 @@
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Security\Acl\Model;
/**
* This method can be implemented by domain objects which you want to store
* ACLs for if they do not have a getId() method, or getId() does not return
* a unique identifier.
*
* @author Johannes M. Schmitt <schmittjoh@gmail.com>
*/
interface DomainObjectInterface
{
/**
* Returns a unique identifier for this domain object.
*
* @return string
*/
public function getObjectIdentifier();
}

View File

@@ -0,0 +1,65 @@
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Security\Acl\Model;
/**
* This class represents an individual entry in the ACL list.
*
* Instances MUST be immutable, as they are returned by the ACL and should not
* allow client modification.
*
* @author Johannes M. Schmitt <schmittjoh@gmail.com>
*/
interface EntryInterface extends \Serializable
{
/**
* The ACL this ACE is associated with.
*
* @return AclInterface
*/
public function getAcl();
/**
* The primary key of this ACE.
*
* @return int
*/
public function getId();
/**
* The permission mask of this ACE.
*
* @return int
*/
public function getMask();
/**
* The security identity associated with this ACE.
*
* @return SecurityIdentityInterface
*/
public function getSecurityIdentity();
/**
* The strategy for comparing masks.
*
* @return string
*/
public function getStrategy();
/**
* Returns whether this ACE is granting, or denying.
*
* @return bool
*/
public function isGranting();
}

View File

@@ -0,0 +1,27 @@
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Security\Acl\Model;
/**
* Interface for entries which are restricted to specific fields.
*
* @author Johannes M. Schmitt <schmittjoh@gmail.com>
*/
interface FieldEntryInterface extends EntryInterface
{
/**
* Returns the field used for this entry.
*
* @return string
*/
public function getField();
}

View File

@@ -0,0 +1,158 @@
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Security\Acl\Model;
/**
* This interface adds mutators for the AclInterface.
*
* All changes to Access Control Entries must go through this interface. Access
* Control Entries must never be modified directly.
*
* @author Johannes M. Schmitt <schmittjoh@gmail.com>
*/
interface MutableAclInterface extends AclInterface
{
/**
* Deletes a class-based ACE.
*
* @param int $index
*/
public function deleteClassAce($index);
/**
* Deletes a class-field-based ACE.
*
* @param int $index
* @param string $field
*/
public function deleteClassFieldAce($index, $field);
/**
* Deletes an object-based ACE.
*
* @param int $index
*/
public function deleteObjectAce($index);
/**
* Deletes an object-field-based ACE.
*
* @param int $index
* @param string $field
*/
public function deleteObjectFieldAce($index, $field);
/**
* Returns the primary key of this ACL.
*
* @return int
*/
public function getId();
/**
* Inserts a class-based ACE.
*
* @param SecurityIdentityInterface $sid
* @param int $mask
* @param int $index
* @param bool $granting
* @param string $strategy
*/
public function insertClassAce(SecurityIdentityInterface $sid, $mask, $index = 0, $granting = true, $strategy = null);
/**
* Inserts a class-field-based ACE.
*
* @param string $field
* @param SecurityIdentityInterface $sid
* @param int $mask
* @param int $index
* @param bool $granting
* @param string $strategy
*/
public function insertClassFieldAce($field, SecurityIdentityInterface $sid, $mask, $index = 0, $granting = true, $strategy = null);
/**
* Inserts an object-based ACE.
*
* @param SecurityIdentityInterface $sid
* @param int $mask
* @param int $index
* @param bool $granting
* @param string $strategy
*/
public function insertObjectAce(SecurityIdentityInterface $sid, $mask, $index = 0, $granting = true, $strategy = null);
/**
* Inserts an object-field-based ACE.
*
* @param string $field
* @param SecurityIdentityInterface $sid
* @param int $mask
* @param int $index
* @param bool $granting
* @param string $strategy
*/
public function insertObjectFieldAce($field, SecurityIdentityInterface $sid, $mask, $index = 0, $granting = true, $strategy = null);
/**
* Sets whether entries are inherited.
*
* @param bool $boolean
*/
public function setEntriesInheriting($boolean);
/**
* Sets the parent ACL.
*
* @param AclInterface|null $acl
*/
public function setParentAcl(AclInterface $acl = null);
/**
* Updates a class-based ACE.
*
* @param int $index
* @param int $mask
* @param string $strategy if null the strategy should not be changed
*/
public function updateClassAce($index, $mask, $strategy = null);
/**
* Updates a class-field-based ACE.
*
* @param int $index
* @param string $field
* @param int $mask
* @param string $strategy if null the strategy should not be changed
*/
public function updateClassFieldAce($index, $field, $mask, $strategy = null);
/**
* Updates an object-based ACE.
*
* @param int $index
* @param int $mask
* @param string $strategy if null the strategy should not be changed
*/
public function updateObjectAce($index, $mask, $strategy = null);
/**
* Updates an object-field-based ACE.
*
* @param int $index
* @param string $field
* @param int $mask
* @param string $strategy if null the strategy should not be changed
*/
public function updateObjectFieldAce($index, $field, $mask, $strategy = null);
}

View File

@@ -0,0 +1,54 @@
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Security\Acl\Model;
use Symfony\Component\Security\Acl\Exception\AclAlreadyExistsException;
/**
* Provides support for creating and storing ACL instances.
*
* @author Johannes M. Schmitt <schmittjoh@gmail.com>
*/
interface MutableAclProviderInterface extends AclProviderInterface
{
/**
* Creates a new ACL for the given object identity.
*
* @param ObjectIdentityInterface $oid
*
* @throws AclAlreadyExistsException when there already is an ACL for the given
* object identity
*
* @return MutableAclInterface
*/
public function createAcl(ObjectIdentityInterface $oid);
/**
* Deletes the ACL for a given object identity.
*
* This will automatically trigger a delete for any child ACLs. If you don't
* want child ACLs to be deleted, you will have to set their parent ACL to null.
*
* @param ObjectIdentityInterface $oid
*/
public function deleteAcl(ObjectIdentityInterface $oid);
/**
* Persists any changes which were made to the ACL, or any associated
* access control entries.
*
* Changes to parent ACLs are not persisted.
*
* @param MutableAclInterface $acl
*/
public function updateAcl(MutableAclInterface $acl);
}

View File

@@ -0,0 +1,50 @@
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Security\Acl\Model;
/**
* Represents the identity of an individual domain object instance.
*
* @author Johannes M. Schmitt <schmittjoh@gmail.com>
*/
interface ObjectIdentityInterface
{
/**
* We specifically require this method so we can check for object equality
* explicitly, and do not have to rely on referencial equality instead.
*
* Though in most cases, both checks should result in the same outcome.
*
* Referential Equality: $object1 === $object2
* Example for Object Equality: $object1->getId() === $object2->getId()
*
* @param ObjectIdentityInterface $identity
*
* @return bool
*/
public function equals(ObjectIdentityInterface $identity);
/**
* Obtains a unique identifier for this object. The identifier must not be
* re-used for other objects with the same type.
*
* @return string cannot return null
*/
public function getIdentifier();
/**
* Returns a type for the domain object. Typically, this is the PHP class name.
*
* @return string cannot return null
*/
public function getType();
}

View File

@@ -0,0 +1,29 @@
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Security\Acl\Model;
/**
* Retrieves the object identity for a given domain object.
*
* @author Johannes M. Schmitt <schmittjoh@gmail.com>
*/
interface ObjectIdentityRetrievalStrategyInterface
{
/**
* Retrieves the object identity from a domain object.
*
* @param object $domainObject
*
* @return ObjectIdentityInterface
*/
public function getObjectIdentity($domainObject);
}

View File

@@ -0,0 +1,45 @@
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Security\Acl\Model;
/**
* Interface used by permission granting implementations.
*
* @author Johannes M. Schmitt <schmittjoh@gmail.com>
*/
interface PermissionGrantingStrategyInterface
{
/**
* Determines whether access to a domain object is to be granted.
*
* @param AclInterface $acl
* @param array $masks
* @param array $sids
* @param bool $administrativeMode
*
* @return bool
*/
public function isGranted(AclInterface $acl, array $masks, array $sids, $administrativeMode = false);
/**
* Determines whether access to a domain object's field is to be granted.
*
* @param AclInterface $acl
* @param string $field
* @param array $masks
* @param array $sids
* @param bool $administrativeMode
*
* @return bool
*/
public function isFieldGranted(AclInterface $acl, $field, array $masks, array $sids, $administrativeMode = false);
}

View File

@@ -0,0 +1,30 @@
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Security\Acl\Model;
/**
* This interface provides an additional level of indirection, so that
* we can work with abstracted versions of security objects and do
* not have to save the entire objects.
*
* @author Johannes M. Schmitt <schmittjoh@gmail.com>
*/
interface SecurityIdentityInterface
{
/**
* This method is used to compare two security identities in order to
* not rely on referential equality.
*
* @param SecurityIdentityInterface $identity
*/
public function equals(SecurityIdentityInterface $identity);
}

View File

@@ -0,0 +1,35 @@
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Security\Acl\Model;
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
/**
* Interface for retrieving security identities from tokens.
*
* @author Johannes M. Schmitt <schmittjoh@gmail.com>
*/
interface SecurityIdentityRetrievalStrategyInterface
{
/**
* Retrieves the available security identities for the given token.
*
* The order in which the security identities are returned is significant.
* Typically, security identities should be ordered from most specific to
* least specific.
*
* @param TokenInterface $token
*
* @return SecurityIdentityInterface[] An array of SecurityIdentityInterface implementations
*/
public function getSecurityIdentities(TokenInterface $token);
}