diff options
44 files changed, 166 insertions, 162 deletions
diff --git a/Acl/Dbal/AclProvider.php b/Acl/Dbal/AclProvider.php index 75093d9..8413843 100644 --- a/Acl/Dbal/AclProvider.php +++ b/Acl/Dbal/AclProvider.php @@ -348,7 +348,6 @@ QUERY; * This method is called when an ACL instance is retrieved from the cache. * * @param AclInterface $acl - * @return void */ private function updateAceIdentityMap(AclInterface $acl) { @@ -397,8 +396,6 @@ QUERY; * map to ensure every ACE only gets instantiated once. * * @param array &$aces - * - * @return void */ private function doUpdateAceIdentityMap(array &$aces) { diff --git a/Acl/Dbal/MutableAclProvider.php b/Acl/Dbal/MutableAclProvider.php index c0a33da..3ae08d3 100644 --- a/Acl/Dbal/MutableAclProvider.php +++ b/Acl/Dbal/MutableAclProvider.php @@ -148,7 +148,6 @@ class MutableAclProvider extends AclProvider implements MutableAclProviderInterf * @param string $propertyName * @param mixed $oldValue * @param mixed $newValue - * @return void */ public function propertyChanged($sender, $propertyName, $oldValue, $newValue) { @@ -643,7 +642,6 @@ QUERY; * Creates the ACL for the passed object identity * * @param ObjectIdentityInterface $oid - * @return void */ private function createObjectIdentity(ObjectIdentityInterface $oid) { @@ -695,7 +693,6 @@ QUERY; * Deletes all ACEs for the given object identity primary key. * * @param integer $oidPK - * @return void */ private function deleteAccessControlEntries($oidPK) { @@ -706,7 +703,6 @@ QUERY; * Deletes the object identity from the database. * * @param integer $pk - * @return void */ private function deleteObjectIdentity($pk) { @@ -717,7 +713,6 @@ QUERY; * Deletes all entries from the relations table from the database. * * @param integer $pk - * @return void */ private function deleteObjectIdentityRelations($pk) { @@ -728,7 +723,6 @@ QUERY; * This regenerates the ancestor table which is used for fast read access. * * @param AclInterface $acl - * @return void */ private function regenerateAncestorRelations(AclInterface $acl) { @@ -749,7 +743,6 @@ QUERY; * * @param string $name * @param array $changes - * @return void */ private function updateFieldAceProperty($name, array $changes) { @@ -806,7 +799,6 @@ QUERY; * * @param string $name * @param array $changes - * @return void */ private function updateAceProperty($name, array $changes) { @@ -860,7 +852,6 @@ QUERY; * Persists the changes which were made to ACEs to the database. * * @param \SplObjectStorage $aces - * @return void */ private function updateAces(\SplObjectStorage $aces) { diff --git a/Acl/Dbal/Schema.php b/Acl/Dbal/Schema.php index dd8cf08..97372f0 100644 --- a/Acl/Dbal/Schema.php +++ b/Acl/Dbal/Schema.php @@ -26,7 +26,6 @@ final class Schema extends BaseSchema * Constructor * * @param array $options the names for tables - * @return void */ public function __construct(array $options) { @@ -43,8 +42,6 @@ final class Schema extends BaseSchema /** * Adds the class table to the schema - * - * @return void */ protected function addClassTable() { @@ -57,8 +54,6 @@ final class Schema extends BaseSchema /** * Adds the entry table to the schema - * - * @return void */ protected function addEntryTable() { @@ -87,8 +82,6 @@ final class Schema extends BaseSchema /** * Adds the object identity table to the schema - * - * @return void */ protected function addObjectIdentitiesTable() { @@ -109,8 +102,6 @@ final class Schema extends BaseSchema /** * Adds the object identity relation table to the schema - * - * @return void */ protected function addObjectIdentityAncestorsTable() { @@ -128,8 +119,6 @@ final class Schema extends BaseSchema /** * Adds the security identity table to the schema - * - * @return void */ protected function addSecurityIdentitiesTable() { diff --git a/Acl/Domain/Acl.php b/Acl/Domain/Acl.php index bb088f8..4a4a2e2 100644 --- a/Acl/Domain/Acl.php +++ b/Acl/Domain/Acl.php @@ -55,7 +55,6 @@ class Acl implements AuditableAclInterface, NotifyPropertyChanged * @param PermissionGrantingStrategyInterface $permissionGrantingStrategy * @param array $loadedSids * @param Boolean $entriesInheriting - * @return void */ public function __construct($id, ObjectIdentityInterface $objectIdentity, PermissionGrantingStrategyInterface $permissionGrantingStrategy, array $loadedSids = array(), $entriesInheriting) { @@ -76,7 +75,6 @@ class Acl implements AuditableAclInterface, NotifyPropertyChanged * Adds a property changed listener * * @param PropertyChangedListener $listener - * @return void */ public function addPropertyChangedListener(PropertyChangedListener $listener) { @@ -282,7 +280,6 @@ class Acl implements AuditableAclInterface, NotifyPropertyChanged * Implementation for the \Serializable interface * * @param string $serialized - * @return void */ public function unserialize($serialized) { @@ -404,7 +401,6 @@ class Acl implements AuditableAclInterface, NotifyPropertyChanged * @param string $property * @param integer $index * @throws \OutOfBoundsException - * @return void */ private function deleteAce($property, $index) { @@ -430,7 +426,6 @@ class Acl implements AuditableAclInterface, NotifyPropertyChanged * @param integer $index * @param string $field * @throws \OutOfBoundsException - * @return void */ private function deleteFieldAce($property, $index, $field) { @@ -460,7 +455,6 @@ class Acl implements AuditableAclInterface, NotifyPropertyChanged * @param string $strategy * @throws \OutOfBoundsException * @throws \InvalidArgumentException - * @return void */ private function insertAce($property, $index, $mask, SecurityIdentityInterface $sid, $granting, $strategy = null) { @@ -510,7 +504,6 @@ class Acl implements AuditableAclInterface, NotifyPropertyChanged * @param string $strategy * @throws \InvalidArgumentException * @throws \OutOfBoundsException - * @return void */ private function insertFieldAce($property, $index, $field, $mask, SecurityIdentityInterface $sid, $granting, $strategy = null) { @@ -564,7 +557,6 @@ class Acl implements AuditableAclInterface, NotifyPropertyChanged * @param integer $mask * @param string $strategy * @throws \OutOfBoundsException - * @return void */ private function updateAce($property, $index, $mask, $strategy = null) { @@ -592,7 +584,6 @@ class Acl implements AuditableAclInterface, NotifyPropertyChanged * @param Boolean $auditSuccess * @param Boolean $auditFailure * @throws \OutOfBoundsException - * @return void */ private function updateAuditing(array &$aces, $index, $auditSuccess, $auditFailure) { @@ -621,7 +612,6 @@ class Acl implements AuditableAclInterface, NotifyPropertyChanged * @param string $strategy * @throws \InvalidArgumentException * @throws \OutOfBoundsException - * @return void */ private function updateFieldAce($property, $index, $field, $mask, $strategy = null) { @@ -651,7 +641,6 @@ class Acl implements AuditableAclInterface, NotifyPropertyChanged * @param string $name * @param mixed $oldValue * @param mixed $newValue - * @return void */ private function onPropertyChanged($name, $oldValue, $newValue) { @@ -667,7 +656,6 @@ class Acl implements AuditableAclInterface, NotifyPropertyChanged * @param string $name * @param mixed $oldValue * @param mixed $newValue - * @return void */ private function onEntryPropertyChanged(EntryInterface $entry, $name, $oldValue, $newValue) { diff --git a/Acl/Domain/AclCollectionCache.php b/Acl/Domain/AclCollectionCache.php index c4f5fdd..33825c1 100644 --- a/Acl/Domain/AclCollectionCache.php +++ b/Acl/Domain/AclCollectionCache.php @@ -32,7 +32,6 @@ class AclCollectionCache * @param AclProviderInterface $aclProvider * @param ObjectIdentityRetrievalStrategy $oidRetrievalStrategy * @param SecurityIdentityRetrievalStrategy $sidRetrievalStrategy - * @return void */ public function __construct(AclProviderInterface $aclProvider, ObjectIdentityRetrievalStrategyInterface $oidRetrievalStrategy, SecurityIdentityRetrievalStrategyInterface $sidRetrievalStrategy) { @@ -47,7 +46,6 @@ class AclCollectionCache * * @param mixed $collection anything that can be passed to foreach() * @param array $tokens an array of TokenInterface implementations - * @return void */ public function cache($collection, array $tokens = array()) { diff --git a/Acl/Domain/AuditLogger.php b/Acl/Domain/AuditLogger.php index 2a6461c..8174873 100644 --- a/Acl/Domain/AuditLogger.php +++ b/Acl/Domain/AuditLogger.php @@ -27,7 +27,6 @@ abstract class AuditLogger implements AuditLoggerInterface * * @param Boolean $granted * @param EntryInterface $ace - * @return void */ public function logIfNeeded($granted, EntryInterface $ace) { @@ -47,7 +46,6 @@ abstract class AuditLogger implements AuditLoggerInterface * * @param Boolean $granted * @param EntryInterface $ace - * @return void */ abstract protected function doLog($granted, EntryInterface $ace); } diff --git a/Acl/Domain/DoctrineAclCache.php b/Acl/Domain/DoctrineAclCache.php index 21e5149..731f98c 100644 --- a/Acl/Domain/DoctrineAclCache.php +++ b/Acl/Domain/DoctrineAclCache.php @@ -36,8 +36,6 @@ class DoctrineAclCache implements AclCacheInterface * @param Cache $cache * @param PermissionGrantingStrategyInterface $permissionGrantingStrategy * @param string $prefix - * - * @return void */ public function __construct(Cache $cache, PermissionGrantingStrategyInterface $permissionGrantingStrategy, $prefix = self::PREFIX) { diff --git a/Acl/Domain/Entry.php b/Acl/Domain/Entry.php index 9a4f560..42449c4 100644 --- a/Acl/Domain/Entry.php +++ b/Acl/Domain/Entry.php @@ -126,7 +126,6 @@ class Entry implements AuditableEntryInterface * AclInterface instead. * * @param Boolean $boolean - * @return void */ public function setAuditFailure($boolean) { @@ -140,7 +139,6 @@ class Entry implements AuditableEntryInterface * AclInterface instead. * * @param Boolean $boolean - * @return void */ public function setAuditSuccess($boolean) { @@ -154,7 +152,6 @@ class Entry implements AuditableEntryInterface * AclInterface instead. * * @param integer $mask - * @return void */ public function setMask($mask) { @@ -168,7 +165,6 @@ class Entry implements AuditableEntryInterface * AclInterface instead. * * @param string $strategy - * @return void */ public function setStrategy($strategy) { @@ -197,7 +193,6 @@ class Entry implements AuditableEntryInterface * Implementation of \Serializable * * @param string $serialized - * @return void */ public function unserialize($serialized) { diff --git a/Acl/Domain/FieldEntry.php b/Acl/Domain/FieldEntry.php index 4167ba4..f057367 100644 --- a/Acl/Domain/FieldEntry.php +++ b/Acl/Domain/FieldEntry.php @@ -36,7 +36,6 @@ class FieldEntry extends Entry implements FieldEntryInterface * @param Boolean $granting * @param Boolean $auditFailure * @param Boolean $auditSuccess - * @return void */ public function __construct($id, AclInterface $acl, $field, SecurityIdentityInterface $sid, $strategy, $mask, $granting, $auditFailure, $auditSuccess) { diff --git a/Acl/Domain/ObjectIdentity.php b/Acl/Domain/ObjectIdentity.php index 42fc67c..2bd152a 100644 --- a/Acl/Domain/ObjectIdentity.php +++ b/Acl/Domain/ObjectIdentity.php @@ -30,7 +30,6 @@ final class ObjectIdentity implements ObjectIdentityInterface * * @param string $identifier * @param string $type - * @return void */ public function __construct($identifier, $type) { diff --git a/Acl/Domain/PermissionGrantingStrategy.php b/Acl/Domain/PermissionGrantingStrategy.php index 5fb8460..c34db2a 100644 --- a/Acl/Domain/PermissionGrantingStrategy.php +++ b/Acl/Domain/PermissionGrantingStrategy.php @@ -35,7 +35,6 @@ class PermissionGrantingStrategy implements PermissionGrantingStrategyInterface * Sets the audit logger * * @param AuditLoggerInterface $auditLogger - * @return void */ public function setAuditLogger(AuditLoggerInterface $auditLogger) { diff --git a/Acl/Domain/RoleSecurityIdentity.php b/Acl/Domain/RoleSecurityIdentity.php index 51d3d0c..0d3d0d2 100644 --- a/Acl/Domain/RoleSecurityIdentity.php +++ b/Acl/Domain/RoleSecurityIdentity.php @@ -27,7 +27,6 @@ final class RoleSecurityIdentity implements SecurityIdentityInterface * Constructor * * @param mixed $role a Role instance, or its string representation - * @return void */ public function __construct($role) { diff --git a/Acl/Domain/SecurityIdentityRetrievalStrategy.php b/Acl/Domain/SecurityIdentityRetrievalStrategy.php index 67312b2..dbc0530 100644 --- a/Acl/Domain/SecurityIdentityRetrievalStrategy.php +++ b/Acl/Domain/SecurityIdentityRetrievalStrategy.php @@ -34,8 +34,6 @@ class SecurityIdentityRetrievalStrategy implements SecurityIdentityRetrievalStra * * @param RoleHierarchyInterface $roleHierarchy * @param AuthenticationTrustResolver $authenticationTrustResolver - * - * @return void */ public function __construct(RoleHierarchyInterface $roleHierarchy, AuthenticationTrustResolver $authenticationTrustResolver) { diff --git a/Acl/Exception/NotAllAclsFoundException.php b/Acl/Exception/NotAllAclsFoundException.php index 8e7a08f..3c02495 100644 --- a/Acl/Exception/NotAllAclsFoundException.php +++ b/Acl/Exception/NotAllAclsFoundException.php @@ -28,7 +28,6 @@ class NotAllAclsFoundException extends AclNotFoundException * Sets the partial result * * @param \SplObjectStorage $result - * @return void */ public function setPartialResult(\SplObjectStorage $result) { diff --git a/Acl/Model/AclCacheInterface.php b/Acl/Model/AclCacheInterface.php index bc6c11f..dd515ce 100644 --- a/Acl/Model/AclCacheInterface.php +++ b/Acl/Model/AclCacheInterface.php @@ -22,7 +22,6 @@ interface AclCacheInterface * Removes an ACL from the cache * * @param string $primaryKey a serialized primary key - * @return void */ function evictFromCacheById($primaryKey); @@ -32,7 +31,6 @@ interface AclCacheInterface * The ACL which is returned, must reference the passed object identity. * * @param ObjectIdentityInterface $oid - * @return void */ function evictFromCacheByIdentity(ObjectIdentityInterface $oid); @@ -56,14 +54,11 @@ interface AclCacheInterface * Stores a new ACL in the cache * * @param AclInterface $acl - * @return void */ function putInCache(AclInterface $acl); /** * Removes all ACLs from the cache - * - * @return void */ function clearCache(); } diff --git a/Acl/Model/AuditLoggerInterface.php b/Acl/Model/AuditLoggerInterface.php index dceb76b..56fd12e 100644 --- a/Acl/Model/AuditLoggerInterface.php +++ b/Acl/Model/AuditLoggerInterface.php @@ -24,7 +24,6 @@ interface AuditLoggerInterface * * @param Boolean $granted * @param EntryInterface $ace - * @return void */ function logIfNeeded($granted, EntryInterface $ace); } diff --git a/Acl/Model/AuditableAclInterface.php b/Acl/Model/AuditableAclInterface.php index 2a6d619..9a95106 100644 --- a/Acl/Model/AuditableAclInterface.php +++ b/Acl/Model/AuditableAclInterface.php @@ -24,7 +24,6 @@ interface AuditableAclInterface extends MutableAclInterface * @param integer $index * @param Boolean $auditSuccess * @param Boolean $auditFailure - * @return void */ function updateClassAuditing($index, $auditSuccess, $auditFailure); @@ -35,9 +34,7 @@ interface AuditableAclInterface extends MutableAclInterface * @param string $field * @param Boolean $auditSuccess * @param Boolean $auditFailure - * @return void */ - function updateClassFieldAuditing($index, $field, $auditSuccess, $auditFailure); /** @@ -46,7 +43,6 @@ interface AuditableAclInterface extends MutableAclInterface * @param integer $index * @param Boolean $auditSuccess * @param Boolean $auditFailure - * @return void */ function updateObjectAuditing($index, $auditSuccess, $auditFailure); @@ -57,7 +53,6 @@ interface AuditableAclInterface extends MutableAclInterface * @param string $field * @param Boolean $auditSuccess * @param Boolean $auditFailure - * @return void */ function updateObjectFieldAuditing($index, $field, $auditSuccess, $auditFailure); } diff --git a/Acl/Model/MutableAclInterface.php b/Acl/Model/MutableAclInterface.php index 54a3f8e..521d307 100644 --- a/Acl/Model/MutableAclInterface.php +++ b/Acl/Model/MutableAclInterface.php @@ -25,7 +25,6 @@ interface MutableAclInterface extends AclInterface * Deletes a class-based ACE * * @param integer $index - * @return void */ function deleteClassAce($index); @@ -34,7 +33,6 @@ interface MutableAclInterface extends AclInterface * * @param integer $index * @param string $field - * @return void */ function deleteClassFieldAce($index, $field); @@ -42,7 +40,6 @@ interface MutableAclInterface extends AclInterface * Deletes an object-based ACE * * @param integer $index - * @return void */ function deleteObjectAce($index); @@ -51,7 +48,6 @@ interface MutableAclInterface extends AclInterface * * @param integer $index * @param string $field - * @return void */ function deleteObjectFieldAce($index, $field); @@ -70,7 +66,6 @@ interface MutableAclInterface extends AclInterface * @param integer $index * @param Boolean $granting * @param string $strategy - * @return void */ function insertClassAce(SecurityIdentityInterface $sid, $mask, $index = 0, $granting = true, $strategy = null); @@ -83,7 +78,6 @@ interface MutableAclInterface extends AclInterface * @param integer $index * @param Boolean $granting * @param string $strategy - * @return void */ function insertClassFieldAce($field, SecurityIdentityInterface $sid, $mask, $index = 0, $granting = true, $strategy = null); @@ -95,7 +89,6 @@ interface MutableAclInterface extends AclInterface * @param integer $index * @param Boolean $granting * @param string $strategy - * @return void */ function insertObjectAce(SecurityIdentityInterface $sid, $mask, $index = 0, $granting = true, $strategy = null); @@ -108,7 +101,6 @@ interface MutableAclInterface extends AclInterface * @param integer $index * @param Boolean $granting * @param string $strategy - * @return void */ function insertObjectFieldAce($field, SecurityIdentityInterface $sid, $mask, $index = 0, $granting = true, $strategy = null); @@ -116,7 +108,6 @@ interface MutableAclInterface extends AclInterface * Sets whether entries are inherited * * @param Boolean $boolean - * @return void */ function setEntriesInheriting($boolean); @@ -124,7 +115,6 @@ interface MutableAclInterface extends AclInterface * Sets the parent ACL * * @param AclInterface $acl - * @return void */ function setParentAcl(AclInterface $acl); @@ -134,7 +124,6 @@ interface MutableAclInterface extends AclInterface * @param integer $index * @param integer $mask * @param string $strategy if null the strategy should not be changed - * @return void */ function updateClassAce($index, $mask, $strategy = null); @@ -145,7 +134,6 @@ interface MutableAclInterface extends AclInterface * @param string $field * @param integer $mask * @param string $strategy if null the strategy should not be changed - * @return void */ function updateClassFieldAce($index, $field, $mask, $strategy = null); @@ -155,7 +143,6 @@ interface MutableAclInterface extends AclInterface * @param integer $index * @param integer $mask * @param string $strategy if null the strategy should not be changed - * @return void */ function updateObjectAce($index, $mask, $strategy = null); @@ -166,7 +153,6 @@ interface MutableAclInterface extends AclInterface * @param string $field * @param integer $mask * @param string $strategy if null the strategy should not be changed - * @return void */ function updateObjectFieldAce($index, $field, $mask, $strategy = null); } diff --git a/Acl/Model/MutableAclProviderInterface.php b/Acl/Model/MutableAclProviderInterface.php index c04eb31..58eeb7d 100644 --- a/Acl/Model/MutableAclProviderInterface.php +++ b/Acl/Model/MutableAclProviderInterface.php @@ -35,7 +35,6 @@ interface MutableAclProviderInterface extends AclProviderInterface * want child ACLs to be deleted, you will have to set their parent ACL to null. * * @param ObjectIdentityInterface $oid - * @return void */ function deleteAcl(ObjectIdentityInterface $oid); @@ -46,7 +45,6 @@ interface MutableAclProviderInterface extends AclProviderInterface * Changes to parent ACLs are not persisted. * * @param MutableAclInterface $acl - * @return void */ function updateAcl(MutableAclInterface $acl); } diff --git a/Acl/Model/SecurityIdentityInterface.php b/Acl/Model/SecurityIdentityInterface.php index 1833630..5bf6189 100644 --- a/Acl/Model/SecurityIdentityInterface.php +++ b/Acl/Model/SecurityIdentityInterface.php @@ -25,7 +25,6 @@ interface SecurityIdentityInterface * not rely on referential equality. * * @param SecurityIdentityInterface $identity - * @return void */ function equals(SecurityIdentityInterface $identity); } diff --git a/Acl/Permission/MaskBuilder.php b/Acl/Permission/MaskBuilder.php index b17233f..44ee274 100644 --- a/Acl/Permission/MaskBuilder.php +++ b/Acl/Permission/MaskBuilder.php @@ -73,7 +73,6 @@ class MaskBuilder * Constructor * * @param integer $mask optional; defaults to 0 - * @return void */ public function __construct($mask = 0) { diff --git a/Core/Authentication/AuthenticationProviderManager.php b/Core/Authentication/AuthenticationProviderManager.php index a82b9fb..7ca46c0 100644 --- a/Core/Authentication/AuthenticationProviderManager.php +++ b/Core/Authentication/AuthenticationProviderManager.php @@ -11,6 +11,10 @@ namespace Symfony\Component\Security\Core\Authentication; +use Symfony\Component\Security\Core\Event\AuthenticationFailureEvent; +use Symfony\Component\Security\Core\Event\AuthenticationEvent; +use Symfony\Component\Security\Core\AuthenticationEvents; +use Symfony\Component\EventDispatcher\EventDispatcherInterface; use Symfony\Component\Security\Core\Exception\AccountStatusException; use Symfony\Component\Security\Core\Exception\AuthenticationException; use Symfony\Component\Security\Core\Exception\ProviderNotFoundException; @@ -22,11 +26,13 @@ use Symfony\Component\Security\Core\Authentication\Token\TokenInterface; * instances to authenticate a Token. * * @author Fabien Potencier <fabien@symfony.com> + * @author Johannes M. Schmitt <schmittjoh@gmail.com> */ class AuthenticationProviderManager implements AuthenticationManagerInterface { private $providers; private $eraseCredentials; + private $eventDispatcher; /** * Constructor. @@ -44,6 +50,11 @@ class AuthenticationProviderManager implements AuthenticationManagerInterface $this->eraseCredentials = (Boolean) $eraseCredentials; } + public function setEventDispatcher(EventDispatcherInterface $dispatcher) + { + $this->eventDispatcher = $dispatcher; + } + /** * {@inheritdoc} */ @@ -77,6 +88,10 @@ class AuthenticationProviderManager implements AuthenticationManagerInterface $result->eraseCredentials(); } + if (null !== $this->eventDispatcher) { + $this->eventDispatcher->dispatch(AuthenticationEvents::AUTHENTICATION_SUCCESS, new AuthenticationEvent($result)); + } + return $result; } @@ -84,6 +99,10 @@ class AuthenticationProviderManager implements AuthenticationManagerInterface $lastException = new ProviderNotFoundException(sprintf('No Authentication Provider found for token of class "%s".', get_class($token))); } + if (null !== $this->eventDispatcher) { + $this->eventDispatcher->dispatch(AuthenticationEvents::AUTHENTICATION_FAILURE, new AuthenticationFailureEvent($token, $lastException)); + } + $lastException->setExtraInformation($token); throw $lastException; diff --git a/Core/Authentication/AuthenticationTrustResolver.php b/Core/Authentication/AuthenticationTrustResolver.php index 8ca28fb..9b3ff3d 100644 --- a/Core/Authentication/AuthenticationTrustResolver.php +++ b/Core/Authentication/AuthenticationTrustResolver.php @@ -28,8 +28,6 @@ class AuthenticationTrustResolver implements AuthenticationTrustResolverInterfac * * @param string $anonymousClass * @param string $rememberMeClass - * - * @return void */ public function __construct($anonymousClass, $rememberMeClass) { diff --git a/Core/Authentication/Provider/AuthenticationProviderInterface.php b/Core/Authentication/Provider/AuthenticationProviderInterface.php index c843216..956adf1 100644 --- a/Core/Authentication/Provider/AuthenticationProviderInterface.php +++ b/Core/Authentication/Provider/AuthenticationProviderInterface.php @@ -15,7 +15,7 @@ use Symfony\Component\Security\Core\Authentication\Token\TokenInterface; use Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface; /** - * AuthenticationProviderInterface is the interface for for all authentication + * AuthenticationProviderInterface is the interface for all authentication * providers. * * Concrete implementations processes specific Token instances. diff --git a/Core/Authentication/Provider/UserAuthenticationProvider.php b/Core/Authentication/Provider/UserAuthenticationProvider.php index ce78df6..f0463ea 100644 --- a/Core/Authentication/Provider/UserAuthenticationProvider.php +++ b/Core/Authentication/Provider/UserAuthenticationProvider.php @@ -65,26 +65,34 @@ abstract class UserAuthenticationProvider implements AuthenticationProviderInter try { $user = $this->retrieveUser($username, $token); - - if (!$user instanceof UserInterface) { - throw new AuthenticationServiceException('retrieveUser() must return a UserInterface.'); + } catch (UsernameNotFoundException $notFound) { + if ($this->hideUserNotFoundExceptions) { + throw new BadCredentialsException('Bad credentials', 0, $notFound); } + throw $notFound; + } + + if (!$user instanceof UserInterface) { + throw new AuthenticationServiceException('retrieveUser() must return a UserInterface.'); + } + + try { $this->userChecker->checkPreAuth($user); $this->checkAuthentication($user, $token); $this->userChecker->checkPostAuth($user); - - $authenticatedToken = new UsernamePasswordToken($user, $token->getCredentials(), $this->providerKey, $user->getRoles()); - $authenticatedToken->setAttributes($token->getAttributes()); - - return $authenticatedToken; - } catch (UsernameNotFoundException $notFound) { + } catch (BadCredentialsException $e) { if ($this->hideUserNotFoundExceptions) { - throw new BadCredentialsException('Bad credentials', 0, $notFound); + throw new BadCredentialsException('Bad credentials', 0, $e); } - throw $notFound; + throw $e; } + + $authenticatedToken = new UsernamePasswordToken($user, $token->getCredentials(), $this->providerKey, $user->getRoles()); + $authenticatedToken->setAttributes($token->getAttributes()); + + return $authenticatedToken; } /** diff --git a/Core/Authentication/Token/RememberMeToken.php b/Core/Authentication/Token/RememberMeToken.php index 7ac9e1c..de50e5c 100644 --- a/Core/Authentication/Token/RememberMeToken.php +++ b/Core/Authentication/Token/RememberMeToken.php @@ -52,7 +52,7 @@ class RememberMeToken extends AbstractToken public function setAuthenticated($authenticated) { if ($authenticated) { - throw new \RuntimeException('You cannot set this token to authenticated after creation.'); + throw new \LogicException('You cannot set this token to authenticated after creation.'); } parent::setAuthenticated(false); diff --git a/Core/AuthenticationEvents.php b/Core/AuthenticationEvents.php new file mode 100644 index 0000000..1e0e6ff --- /dev/null +++ b/Core/AuthenticationEvents.php @@ -0,0 +1,19 @@ +<?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\Core; + +final class AuthenticationEvents +{ + const AUTHENTICATION_SUCCESS = 'security.authentication.success'; + + const AUTHENTICATION_FAILURE = 'security.authentication.failure'; +} diff --git a/Core/Authorization/Voter/AuthenticatedVoter.php b/Core/Authorization/Voter/AuthenticatedVoter.php index d750e33..5847e0d 100644 --- a/Core/Authorization/Voter/AuthenticatedVoter.php +++ b/Core/Authorization/Voter/AuthenticatedVoter.php @@ -35,8 +35,6 @@ class AuthenticatedVoter implements VoterInterface * Constructor. * * @param AuthenticationTrustResolverInterface $authenticationTrustResolver - * - * @return void */ public function __construct(AuthenticationTrustResolverInterface $authenticationTrustResolver) { diff --git a/Core/Event/AuthenticationEvent.php b/Core/Event/AuthenticationEvent.php new file mode 100644 index 0000000..132cea9 --- /dev/null +++ b/Core/Event/AuthenticationEvent.php @@ -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\Core\Event; + +use Symfony\Component\Security\Core\Authentication\Token\TokenInterface; +use Symfony\Component\EventDispatcher\Event; + +/** + * This is a general purpose authentication event. + * + * @author Johannes M. Schmitt <schmittjoh@gmail.com> + */ +class AuthenticationEvent extends Event +{ + private $authenticationToken; + + public function __construct(TokenInterface $token) + { + $this->authenticationToken = $token; + } + + public function getAuthenticationToken() + { + return $this->authenticationToken; + } +} diff --git a/Core/Event/AuthenticationFailureEvent.php b/Core/Event/AuthenticationFailureEvent.php new file mode 100644 index 0000000..6705fc9 --- /dev/null +++ b/Core/Event/AuthenticationFailureEvent.php @@ -0,0 +1,37 @@ +<?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\Core\Event; + +use Symfony\Component\Security\Core\Exception\AuthenticationException; +use Symfony\Component\Security\Core\Authentication\Token\TokenInterface; + +/** + * This event is dispatched on authentication failure. + * + * @author Johannes M. Schmitt <schmittjoh@gmail.com> + */ +class AuthenticationFailureEvent extends AuthenticationEvent +{ + private $authenticationException; + + public function __construct(TokenInterface $token, AuthenticationException $ex) + { + parent::__construct($token); + + $this->authenticationException = $ex; + } + + public function getAuthenticationException() + { + return $this->authenticationException; + } +} diff --git a/Core/SecurityContextInterface.php b/Core/SecurityContextInterface.php index 46b2cc4..960a4cd 100644 --- a/Core/SecurityContextInterface.php +++ b/Core/SecurityContextInterface.php @@ -35,8 +35,6 @@ interface SecurityContextInterface * Sets the authentication token. * * @param TokenInterface $token - * - * @return void */ function setToken(TokenInterface $token = null); diff --git a/Http/Firewall/AbstractAuthenticationListener.php b/Http/Firewall/AbstractAuthenticationListener.php index 1765f7f..99f92b8 100644 --- a/Http/Firewall/AbstractAuthenticationListener.php +++ b/Http/Firewall/AbstractAuthenticationListener.php @@ -273,7 +273,7 @@ abstract class AbstractAuthenticationListener implements ListenerInterface return $targetUrl; } - if ($this->options['use_referer'] && $targetUrl = $request->headers->get('Referer')) { + if ($this->options['use_referer'] && ($targetUrl = $request->headers->get('Referer')) && $targetUrl !== $request->getUriForPath($this->options['login_path'])) { return $targetUrl; } diff --git a/Http/Firewall/ContextListener.php b/Http/Firewall/ContextListener.php index d282452..96b8f07 100644 --- a/Http/Firewall/ContextListener.php +++ b/Http/Firewall/ContextListener.php @@ -22,6 +22,7 @@ use Symfony\Component\Security\Core\Exception\UsernameNotFoundException; use Symfony\Component\Security\Core\Exception\UnsupportedUserException; use Symfony\Component\Security\Core\SecurityContext; use Symfony\Component\Security\Core\User\UserInterface; +use Symfony\Component\Security\Core\User\UserProviderInterface; use Symfony\Component\EventDispatcher\EventDispatcherInterface; /** @@ -43,6 +44,12 @@ class ContextListener implements ListenerInterface throw new \InvalidArgumentException('$contextKey must not be empty.'); } + foreach ($userProviders as $userProvider) { + if (!$userProvider instanceof UserProviderInterface) { + throw new \InvalidArgumentException(sprintf('User provider "%s" must implement "Symfony\Component\Security\Core\User\UserProviderInterface".', get_class($userProvider))); + } + } + $this->context = $context; $this->userProviders = $userProviders; $this->contextKey = $contextKey; @@ -96,19 +103,19 @@ class ContextListener implements ListenerInterface return; } - if (null === $token = $this->context->getToken()) { - return; + if (null !== $this->logger) { + $this->logger->debug('Write SecurityContext in the session'); } - if (null === $token || $token instanceof AnonymousToken) { + if (null === $session = $event->getRequest()->getSession()) { return; } - if (null !== $this->logger) { - $this->logger->debug('Write SecurityContext in the session'); + if ((null === $token = $this->context->getToken()) || ($token instanceof AnonymousToken)) { + $session->remove('_security_'.$this->contextKey); + } else { + $session->set('_security_'.$this->contextKey, serialize($token)); } - - $event->getRequest()->getSession()->set('_security_'.$this->contextKey, serialize($token)); } /** diff --git a/Http/Firewall/ExceptionListener.php b/Http/Firewall/ExceptionListener.php index 1535b9b..674c648 100644 --- a/Http/Firewall/ExceptionListener.php +++ b/Http/Firewall/ExceptionListener.php @@ -15,7 +15,6 @@ use Symfony\Component\HttpFoundation\Response; use Symfony\Component\Security\Http\Authorization\AccessDeniedHandlerInterface; use Symfony\Component\Security\Core\SecurityContextInterface; use Symfony\Component\Security\Core\Authentication\AuthenticationTrustResolverInterface; -use Symfony\Component\Security\Core\Authentication\Token\UsernamePasswordToken; use Symfony\Component\Security\Http\EntryPoint\AuthenticationEntryPointInterface; use Symfony\Component\Security\Core\Exception\AccountStatusException; use Symfony\Component\Security\Core\Exception\AuthenticationException; @@ -160,10 +159,9 @@ class ExceptionListener $this->setTargetPath($request); - if ($authException instanceof AccountStatusException && ($token = $this->context->getToken()) instanceof UsernamePasswordToken) { + if ($authException instanceof AccountStatusException) { // remove the security token to prevent infinite redirect loops $this->context->setToken(null); - $request->getSession()->remove('_security_' . $token->getProviderKey()); } return $this->authenticationEntryPoint->start($request, $authException); diff --git a/Http/Firewall/LogoutListener.php b/Http/Firewall/LogoutListener.php index 4bfa7e1..bb90b6a 100644 --- a/Http/Firewall/LogoutListener.php +++ b/Http/Firewall/LogoutListener.php @@ -16,6 +16,7 @@ use Symfony\Component\Security\Http\Logout\LogoutSuccessHandlerInterface; use Symfony\Component\Security\Http\Logout\LogoutHandlerInterface; use Symfony\Component\Security\Core\SecurityContextInterface; use Symfony\Component\Security\Http\HttpUtils; +use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpKernel\Event\GetResponseEvent; @@ -56,8 +57,6 @@ class LogoutListener implements ListenerInterface * Adds a logout handler * * @param LogoutHandlerInterface $handler - * - * @return void */ public function addHandler(LogoutHandlerInterface $handler) { @@ -73,7 +72,7 @@ class LogoutListener implements ListenerInterface { $request = $event->getRequest(); - if (!$this->httpUtils->checkRequestPath($request, $this->logoutPath)) { + if (!$this->requiresLogout($request)) { return; } @@ -98,4 +97,20 @@ class LogoutListener implements ListenerInterface $event->setResponse($response); } + + /** + * Whether this request is asking for logout. + * + * The default implementation only processed requests to a specific path, + * but a subclass could change this to logout requests where + * certain parameters is present. + * + * @param Request $request + * + * @return Boolean + */ + protected function requiresLogout(Request $request) + { + return $this->httpUtils->checkRequestPath($request, $this->logoutPath); + } } diff --git a/Http/HttpUtils.php b/Http/HttpUtils.php index cac130e..f62f84d 100644 --- a/Http/HttpUtils.php +++ b/Http/HttpUtils.php @@ -52,7 +52,6 @@ class HttpUtils if ('/' === $path[0]) { $path = $request->getUriForPath($path); } elseif (0 !== strpos($path, 'http')) { - $this->resetLocale($request); $path = $this->generateUrl($path, true); } @@ -70,7 +69,6 @@ class HttpUtils public function createRequest(Request $request, $path) { if ($path && '/' !== $path[0] && 0 !== strpos($path, 'http')) { - $this->resetLocale($request); $path = $this->generateUrl($path, true); } if (0 !== strpos($path, 'http')) { @@ -120,27 +118,6 @@ class HttpUtils return $path === $request->getPathInfo(); } - // hack (don't have a better solution for now) - private function resetLocale(Request $request) - { - $context = $this->router->getContext(); - if ($context->getParameter('_locale')) { - return; - } - - try { - $parameters = $this->router->match($request->getPathInfo()); - - if (isset($parameters['_locale'])) { - $context->setParameter('_locale', $parameters['_locale']); - } elseif ($session = $request->getSession()) { - $context->setParameter('_locale', $session->getLocale()); - } - } catch (\Exception $e) { - // let's hope user doesn't use the locale in the path - } - } - private function generateUrl($route, $absolute = false) { if (null === $this->router) { diff --git a/Http/Logout/CookieClearingLogoutHandler.php b/Http/Logout/CookieClearingLogoutHandler.php index ddb24e3..6838be5 100644 --- a/Http/Logout/CookieClearingLogoutHandler.php +++ b/Http/Logout/CookieClearingLogoutHandler.php @@ -40,8 +40,6 @@ class CookieClearingLogoutHandler implements LogoutHandlerInterface * @param Request $request * @param Response $response * @param TokenInterface $token - * - * @return void */ public function logout(Request $request, Response $response, TokenInterface $token) { diff --git a/Http/Logout/LogoutHandlerInterface.php b/Http/Logout/LogoutHandlerInterface.php index 079cc00..71be388 100644 --- a/Http/Logout/LogoutHandlerInterface.php +++ b/Http/Logout/LogoutHandlerInterface.php @@ -30,8 +30,6 @@ interface LogoutHandlerInterface * @param Request $request * @param Response $response * @param TokenInterface $token - * - * @return void */ function logout(Request $request, Response $response, TokenInterface $token); } diff --git a/Http/Logout/SessionLogoutHandler.php b/Http/Logout/SessionLogoutHandler.php index 0a7e5cd..e91cf17 100644 --- a/Http/Logout/SessionLogoutHandler.php +++ b/Http/Logout/SessionLogoutHandler.php @@ -28,8 +28,6 @@ class SessionLogoutHandler implements LogoutHandlerInterface * @param Request $request * @param Response $response * @param TokenInterface $token - * - * @return void */ public function logout(Request $request, Response $response, TokenInterface $token) { diff --git a/Http/RememberMe/AbstractRememberMeServices.php b/Http/RememberMe/AbstractRememberMeServices.php index 94f8830..2bf8734 100644 --- a/Http/RememberMe/AbstractRememberMeServices.php +++ b/Http/RememberMe/AbstractRememberMeServices.php @@ -144,8 +144,6 @@ abstract class AbstractRememberMeServices implements RememberMeServicesInterface * @param Request $request * @param Response $response * @param TokenInterface $token - * - * @return void */ public function logout(Request $request, Response $response, TokenInterface $token) { @@ -157,8 +155,6 @@ abstract class AbstractRememberMeServices implements RememberMeServicesInterface * an attempted authentication fails. * * @param Request $request - * - * @return void */ public final function loginFail(Request $request) { @@ -173,8 +169,6 @@ abstract class AbstractRememberMeServices implements RememberMeServicesInterface * @param Request $request * @param Response $response * @param TokenInterface $token The token that resulted in a successful authentication - * - * @return void */ public final function loginSuccess(Request $request, Response $response, TokenInterface $token) { @@ -224,8 +218,6 @@ abstract class AbstractRememberMeServices implements RememberMeServicesInterface * @param Request $request * @param Response $response * @param TokenInterface $token - * - * @return void */ abstract protected function onLoginSuccess(Request $request, Response $response, TokenInterface $token); @@ -268,8 +260,6 @@ abstract class AbstractRememberMeServices implements RememberMeServicesInterface * Deletes the remember-me cookie * * @param Request $request - * - * @return void */ protected function cancelCookie(Request $request) { diff --git a/Http/RememberMe/PersistentTokenBasedRememberMeServices.php b/Http/RememberMe/PersistentTokenBasedRememberMeServices.php index e9d22ba..b87c9e4 100644 --- a/Http/RememberMe/PersistentTokenBasedRememberMeServices.php +++ b/Http/RememberMe/PersistentTokenBasedRememberMeServices.php @@ -35,8 +35,6 @@ class PersistentTokenBasedRememberMeServices extends AbstractRememberMeServices * Sets the token provider * * @param TokenProviderInterface $tokenProvider - * - * @return void */ public function setTokenProvider(TokenProviderInterface $tokenProvider) { diff --git a/Http/RememberMe/RememberMeServicesInterface.php b/Http/RememberMe/RememberMeServicesInterface.php index b824538..0497c69 100644 --- a/Http/RememberMe/RememberMeServicesInterface.php +++ b/Http/RememberMe/RememberMeServicesInterface.php @@ -60,8 +60,6 @@ interface RememberMeServicesInterface * This method needs to take care of invalidating the cookie. * * @param Request $request - * - * @return void */ function loginFail(Request $request); @@ -79,8 +77,6 @@ interface RememberMeServicesInterface * @param Request $request * @param Response $response * @param TokenInterface $token - * - * @return void */ function loginSuccess(Request $request, Response $response, TokenInterface $token); } diff --git a/Http/Session/SessionAuthenticationStrategyInterface.php b/Http/Session/SessionAuthenticationStrategyInterface.php index 54924ac..5bc6b80 100644 --- a/Http/Session/SessionAuthenticationStrategyInterface.php +++ b/Http/Session/SessionAuthenticationStrategyInterface.php @@ -32,8 +32,6 @@ interface SessionAuthenticationStrategyInterface * * @param Request $request * @param TokenInterface $token - * - * @return void */ function onAuthentication(Request $request, TokenInterface $token); } diff --git a/composer.json b/composer.json index 1bb1d56..8fa4ffc 100644 --- a/composer.json +++ b/composer.json @@ -4,6 +4,7 @@ "description": "Symfony Security Component", "keywords": [], "homepage": "http://symfony.com", + "version": "2.1.0", "license": "MIT", "authors": [ { |