Upgrade 1-11.38

This commit is contained in:
xesmyd
2026-03-30 14:10:30 +02:00
parent f2a7e6d1fc
commit ac648ef29d
24665 changed files with 69682 additions and 2205004 deletions
@@ -11,11 +11,11 @@
namespace Symfony\Component\Security\Core\User;
use Symfony\Component\Security\Core\Exception\AccountStatusException;
use Symfony\Component\Security\Core\Exception\AccountExpiredException;
use Symfony\Component\Security\Core\Exception\LockedException;
use Symfony\Component\Security\Core\Exception\AccountStatusException;
use Symfony\Component\Security\Core\Exception\CredentialsExpiredException;
use Symfony\Component\Security\Core\Exception\DisabledException;
use Symfony\Component\Security\Core\Exception\LockedException;
/**
* Adds extra features to a user class related to account status flags.
+13 -2
View File
@@ -26,7 +26,10 @@ class ChainUserProvider implements UserProviderInterface
{
private $providers;
public function __construct(array $providers)
/**
* @param iterable|UserProviderInterface[] $providers
*/
public function __construct($providers)
{
$this->providers = $providers;
}
@@ -36,6 +39,10 @@ class ChainUserProvider implements UserProviderInterface
*/
public function getProviders()
{
if ($this->providers instanceof \Traversable) {
return iterator_to_array($this->providers);
}
return $this->providers;
}
@@ -66,6 +73,10 @@ class ChainUserProvider implements UserProviderInterface
foreach ($this->providers as $provider) {
try {
if (!$provider->supportsClass(\get_class($user))) {
continue;
}
return $provider->refreshUser($user);
} catch (UnsupportedUserException $e) {
// try next one
@@ -80,7 +91,7 @@ class ChainUserProvider implements UserProviderInterface
$e->setUsername($user->getUsername());
throw $e;
} else {
throw new UnsupportedUserException(sprintf('The account "%s" is not supported.', get_class($user)));
throw new UnsupportedUserException(sprintf('There is no user provider for user "%s". Shouldn\'t the "supportsClass()" method of your user provider return true for this classname?', \get_class($user)));
}
}
@@ -29,8 +29,6 @@ interface EquatableInterface
* Also implementation should consider that $user instance may implement
* the extended user interface `AdvancedUserInterface`.
*
* @param UserInterface $user
*
* @return bool
*/
public function isEqualTo(UserInterface $user);
+6 -10
View File
@@ -11,8 +11,8 @@
namespace Symfony\Component\Security\Core\User;
use Symfony\Component\Security\Core\Exception\UsernameNotFoundException;
use Symfony\Component\Security\Core\Exception\UnsupportedUserException;
use Symfony\Component\Security\Core\Exception\UsernameNotFoundException;
/**
* InMemoryUserProvider is a simple non persistent user provider.
@@ -27,19 +27,17 @@ class InMemoryUserProvider implements UserProviderInterface
private $users;
/**
* Constructor.
*
* The user array is a hash where the keys are usernames and the values are
* an array of attributes: 'password', 'enabled', and 'roles'.
*
* @param array $users An array of users
*/
public function __construct(array $users = array())
public function __construct(array $users = [])
{
foreach ($users as $username => $attributes) {
$password = isset($attributes['password']) ? $attributes['password'] : null;
$enabled = isset($attributes['enabled']) ? $attributes['enabled'] : true;
$roles = isset($attributes['roles']) ? $attributes['roles'] : array();
$roles = isset($attributes['roles']) ? $attributes['roles'] : [];
$user = new User($username, $password, $roles, $enabled, true, true, true);
$this->createUser($user);
@@ -49,8 +47,6 @@ class InMemoryUserProvider implements UserProviderInterface
/**
* Adds a new User to the provider.
*
* @param UserInterface $user A UserInterface instance
*
* @throws \LogicException
*/
public function createUser(UserInterface $user)
@@ -78,7 +74,7 @@ class InMemoryUserProvider implements UserProviderInterface
public function refreshUser(UserInterface $user)
{
if (!$user instanceof User) {
throw new UnsupportedUserException(sprintf('Instances of "%s" are not supported.', get_class($user)));
throw new UnsupportedUserException(sprintf('Instances of "%s" are not supported.', \get_class($user)));
}
$storedUser = $this->getUser($user->getUsername());
@@ -91,7 +87,7 @@ class InMemoryUserProvider implements UserProviderInterface
*/
public function supportsClass($class)
{
return $class === 'Symfony\Component\Security\Core\User\User';
return 'Symfony\Component\Security\Core\User\User' === $class;
}
/**
@@ -101,7 +97,7 @@ class InMemoryUserProvider implements UserProviderInterface
*
* @return User
*
* @throws UsernameNotFoundException If user whose given username does not exist.
* @throws UsernameNotFoundException if user whose given username does not exist
*/
private function getUser($username)
{
+15 -18
View File
@@ -12,11 +12,11 @@
namespace Symfony\Component\Security\Core\User;
use Symfony\Component\Ldap\Entry;
use Symfony\Component\Ldap\Exception\ConnectionException;
use Symfony\Component\Ldap\LdapInterface;
use Symfony\Component\Security\Core\Exception\InvalidArgumentException;
use Symfony\Component\Security\Core\Exception\UnsupportedUserException;
use Symfony\Component\Security\Core\Exception\UsernameNotFoundException;
use Symfony\Component\Ldap\Exception\ConnectionException;
use Symfony\Component\Ldap\LdapInterface;
/**
* LdapUserProvider is a simple user provider on top of ldap.
@@ -36,16 +36,14 @@ class LdapUserProvider implements UserProviderInterface
private $passwordAttribute;
/**
* @param LdapInterface $ldap
* @param string $baseDn
* @param string $searchDn
* @param string $searchPassword
* @param array $defaultRoles
* @param string $uidKey
* @param string $filter
* @param string $passwordAttribute
* @param string $baseDn
* @param string $searchDn
* @param string $searchPassword
* @param string $uidKey
* @param string $filter
* @param string $passwordAttribute
*/
public function __construct(LdapInterface $ldap, $baseDn, $searchDn = null, $searchPassword = null, array $defaultRoles = array(), $uidKey = 'sAMAccountName', $filter = '({uid_key}={username})', $passwordAttribute = null)
public function __construct(LdapInterface $ldap, $baseDn, $searchDn = null, $searchPassword = null, array $defaultRoles = [], $uidKey = 'sAMAccountName', $filter = '({uid_key}={username})', $passwordAttribute = null)
{
if (null === $uidKey) {
$uidKey = 'sAMAccountName';
@@ -76,14 +74,14 @@ class LdapUserProvider implements UserProviderInterface
}
$entries = $search->execute();
$count = count($entries);
$count = \count($entries);
if (!$count) {
throw new UsernameNotFoundException(sprintf('User "%s" not found.', $username));
}
if ($count > 1) {
throw new UsernameNotFoundException('More than one user found');
throw new UsernameNotFoundException('More than one user found.');
}
$entry = $entries[0];
@@ -104,7 +102,7 @@ class LdapUserProvider implements UserProviderInterface
public function refreshUser(UserInterface $user)
{
if (!$user instanceof User) {
throw new UnsupportedUserException(sprintf('Instances of "%s" are not supported.', get_class($user)));
throw new UnsupportedUserException(sprintf('Instances of "%s" are not supported.', \get_class($user)));
}
return new User($user->getUsername(), null, $user->getRoles());
@@ -115,14 +113,13 @@ class LdapUserProvider implements UserProviderInterface
*/
public function supportsClass($class)
{
return $class === 'Symfony\Component\Security\Core\User\User';
return 'Symfony\Component\Security\Core\User\User' === $class;
}
/**
* Loads a user from an LDAP entry.
*
* @param string $username
* @param Entry $entry
*
* @return User
*/
@@ -140,7 +137,7 @@ class LdapUserProvider implements UserProviderInterface
/**
* Fetches a required unique attribute value from an LDAP entry.
*
* @param null|Entry $entry
* @param Entry|null $entry
* @param string $attribute
*/
private function getAttributeValue(Entry $entry, $attribute)
@@ -151,7 +148,7 @@ class LdapUserProvider implements UserProviderInterface
$values = $entry->getAttribute($attribute);
if (1 !== count($values)) {
if (1 !== \count($values)) {
throw new InvalidArgumentException(sprintf('Attribute "%s" has multiple values.', $attribute));
}
+2 -1
View File
@@ -28,7 +28,7 @@ final class User implements AdvancedUserInterface
private $accountNonLocked;
private $roles;
public function __construct($username, $password, array $roles = array(), $enabled = true, $userNonExpired = true, $credentialsNonExpired = true, $userNonLocked = true)
public function __construct($username, $password, array $roles = [], $enabled = true, $userNonExpired = true, $credentialsNonExpired = true, $userNonLocked = true)
{
if ('' === $username || null === $username) {
throw new \InvalidArgumentException('The username cannot be empty.');
@@ -69,6 +69,7 @@ final class User implements AdvancedUserInterface
*/
public function getSalt()
{
return null;
}
/**
+3 -3
View File
@@ -11,10 +11,10 @@
namespace Symfony\Component\Security\Core\User;
use Symfony\Component\Security\Core\Exception\CredentialsExpiredException;
use Symfony\Component\Security\Core\Exception\LockedException;
use Symfony\Component\Security\Core\Exception\DisabledException;
use Symfony\Component\Security\Core\Exception\AccountExpiredException;
use Symfony\Component\Security\Core\Exception\CredentialsExpiredException;
use Symfony\Component\Security\Core\Exception\DisabledException;
use Symfony\Component\Security\Core\Exception\LockedException;
/**
* UserChecker checks the user account flags.
@@ -26,8 +26,6 @@ interface UserCheckerInterface
/**
* Checks the user account before authentication.
*
* @param UserInterface $user a UserInterface instance
*
* @throws AccountStatusException
*/
public function checkPreAuth(UserInterface $user);
@@ -35,8 +33,6 @@ interface UserCheckerInterface
/**
* Checks the user account after authentication.
*
* @param UserInterface $user a UserInterface instance
*
* @throws AccountStatusException
*/
public function checkPostAuth(UserInterface $user);
+8 -10
View File
@@ -21,10 +21,10 @@ use Symfony\Component\Security\Core\Role\Role;
* password (for checking against a submitted password), assigning roles
* and so on.
*
* Regardless of how your user are loaded or where they come from (a database,
* configuration, web service, etc), you will have a class that implements
* Regardless of how your users are loaded or where they come from (a database,
* configuration, web service, etc.), you will have a class that implements
* this interface. Objects that implement this interface are created and
* loaded by different objects that implement UserProviderInterface
* loaded by different objects that implement UserProviderInterface.
*
* @see UserProviderInterface
* @see AdvancedUserInterface
@@ -36,12 +36,10 @@ interface UserInterface
/**
* Returns the roles granted to the user.
*
* <code>
* public function getRoles()
* {
* return array('ROLE_USER');
* }
* </code>
* public function getRoles()
* {
* return ['ROLE_USER'];
* }
*
* Alternatively, the roles might be stored on a ``roles`` property,
* and populated in any number of different ways when the user object
@@ -57,7 +55,7 @@ interface UserInterface
* This should be the encoded password. On authentication, a plain-text
* password will be salted, encoded, and then compared to this value.
*
* @return string The password
* @return string|null The encoded password if any
*/
public function getPassword();
@@ -11,8 +11,8 @@
namespace Symfony\Component\Security\Core\User;
use Symfony\Component\Security\Core\Exception\UsernameNotFoundException;
use Symfony\Component\Security\Core\Exception\UnsupportedUserException;
use Symfony\Component\Security\Core\Exception\UsernameNotFoundException;
/**
* Represents a class that loads UserInterface objects from some source for the authentication system.
@@ -55,8 +55,6 @@ interface UserProviderInterface
* object can just be merged into some internal array of users / identity
* map.
*
* @param UserInterface $user
*
* @return UserInterface
*
* @throws UnsupportedUserException if the user is not supported