login consent app sql

This commit is contained in:
2022-05-03 08:54:45 +02:00
parent e7253acfd8
commit f9a6535906
1652 changed files with 187600 additions and 45 deletions

View File

@ -0,0 +1,153 @@
<?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\User;
use Symfony\Component\Security\Core\Exception\UnsupportedUserException;
use Symfony\Component\Security\Core\Exception\UserNotFoundException;
/**
* Chain User Provider.
*
* This provider calls several leaf providers in a chain until one is able to
* handle the request.
*
* @author Johannes M. Schmitt <schmittjoh@gmail.com>
*/
class ChainUserProvider implements UserProviderInterface, PasswordUpgraderInterface
{
private $providers;
/**
* @param iterable<array-key, UserProviderInterface> $providers
*/
public function __construct(iterable $providers)
{
$this->providers = $providers;
}
/**
* @return UserProviderInterface[]
*/
public function getProviders()
{
if ($this->providers instanceof \Traversable) {
return iterator_to_array($this->providers);
}
return $this->providers;
}
/**
* {@inheritdoc}
*/
public function loadUserByUsername(string $username)
{
trigger_deprecation('symfony/security-core', '5.3', 'Method "%s()" is deprecated, use loadUserByIdentifier() instead.', __METHOD__);
return $this->loadUserByIdentifier($username);
}
public function loadUserByIdentifier(string $identifier): UserInterface
{
foreach ($this->providers as $provider) {
try {
// @deprecated since Symfony 5.3, change to $provider->loadUserByIdentifier() in 6.0
if (!method_exists($provider, 'loadUserByIdentifier')) {
trigger_deprecation('symfony/security-core', '5.3', 'Not implementing method "loadUserByIdentifier()" in user provider "%s" is deprecated. This method will replace "loadUserByUsername()" in Symfony 6.0.', get_debug_type($provider));
return $provider->loadUserByUsername($identifier);
}
return $provider->loadUserByIdentifier($identifier);
} catch (UserNotFoundException $e) {
// try next one
}
}
$ex = new UserNotFoundException(sprintf('There is no user with identifier "%s".', $identifier));
$ex->setUserIdentifier($identifier);
throw $ex;
}
/**
* {@inheritdoc}
*/
public function refreshUser(UserInterface $user)
{
$supportedUserFound = false;
foreach ($this->providers as $provider) {
try {
if (!$provider->supportsClass(get_debug_type($user))) {
continue;
}
return $provider->refreshUser($user);
} catch (UnsupportedUserException $e) {
// try next one
} catch (UserNotFoundException $e) {
$supportedUserFound = true;
// try next one
}
}
if ($supportedUserFound) {
// @deprecated since Symfony 5.3, change to $user->getUserIdentifier() in 6.0
$username = method_exists($user, 'getUserIdentifier') ? $user->getUserIdentifier() : $user->getUsername();
$e = new UserNotFoundException(sprintf('There is no user with name "%s".', $username));
$e->setUserIdentifier($username);
throw $e;
} else {
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_debug_type($user)));
}
}
/**
* {@inheritdoc}
*/
public function supportsClass(string $class)
{
foreach ($this->providers as $provider) {
if ($provider->supportsClass($class)) {
return true;
}
}
return false;
}
/**
* @param PasswordAuthenticatedUserInterface $user
*
* {@inheritdoc}
*/
public function upgradePassword($user, string $newHashedPassword): void
{
if (!$user instanceof PasswordAuthenticatedUserInterface) {
trigger_deprecation('symfony/security-core', '5.3', 'The "%s::upgradePassword()" method expects an instance of "%s" as first argument, the "%s" class should implement it.', PasswordUpgraderInterface::class, PasswordAuthenticatedUserInterface::class, get_debug_type($user));
if (!$user instanceof UserInterface) {
throw new \TypeError(sprintf('The "%s::upgradePassword()" method expects an instance of "%s" as first argument, "%s" given.', static::class, PasswordAuthenticatedUserInterface::class, get_debug_type($user)));
}
}
foreach ($this->providers as $provider) {
if ($provider instanceof PasswordUpgraderInterface) {
try {
$provider->upgradePassword($user, $newHashedPassword);
} catch (UnsupportedUserException $e) {
// ignore: password upgrades are opportunistic
}
}
}
}
}

View File

@ -0,0 +1,32 @@
<?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\User;
/**
* EquatableInterface used to test if two objects are equal in security
* and re-authentication context.
*
* @author Dariusz Górecki <darek.krk@gmail.com>
*/
interface EquatableInterface
{
/**
* The equality comparison should neither be done by referential equality
* nor by comparing identities (i.e. getId() === getId()).
*
* However, you do not need to compare every attribute, but only those that
* are relevant for assessing whether re-authentication is required.
*
* @return bool
*/
public function isEqualTo(UserInterface $user);
}

View File

@ -0,0 +1,76 @@
<?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\User;
/**
* UserInterface implementation used by the in-memory user provider.
*
* This should not be used for anything else.
*
* @author Robin Chalas <robin.chalas@gmail.com>
* @author Fabien Potencier <fabien@symfony.com>
*/
final class InMemoryUser extends User
{
/**
* {@inheritdoc}
*
* @deprecated since Symfony 5.3
*/
public function isAccountNonExpired(): bool
{
trigger_deprecation('symfony/security-core', '5.3', 'Method "%s()" is deprecated, you should stop using it.', __METHOD__);
return parent::isAccountNonExpired();
}
/**
* {@inheritdoc}
*
* @deprecated since Symfony 5.3
*/
public function isAccountNonLocked(): bool
{
trigger_deprecation('symfony/security-core', '5.3', 'Method "%s()" is deprecated, you should stop using it.', __METHOD__);
return parent::isAccountNonLocked();
}
/**
* {@inheritdoc}
*
* @deprecated since Symfony 5.3
*/
public function isCredentialsNonExpired(): bool
{
trigger_deprecation('symfony/security-core', '5.3', 'Method "%s()" is deprecated, you should stop using it.', __METHOD__);
return parent::isCredentialsNonExpired();
}
/**
* @deprecated since Symfony 5.3
*/
public function getExtraFields(): array
{
trigger_deprecation('symfony/security-core', '5.3', 'Method "%s()" is deprecated, you should stop using it.', __METHOD__);
return parent::getExtraFields();
}
public function setPassword(string $password)
{
trigger_deprecation('symfony/security-core', '5.3', 'Method "%s()" is deprecated, you should stop using it.', __METHOD__);
parent::setPassword($password);
}
}

View File

@ -0,0 +1,73 @@
<?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\User;
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;
/**
* Checks the state of the in-memory user account.
*
* @author Fabien Potencier <fabien@symfony.com>
*/
class InMemoryUserChecker implements UserCheckerInterface
{
public function checkPreAuth(UserInterface $user)
{
// @deprecated since Symfony 5.3, in 6.0 change to:
// if (!$user instanceof InMemoryUser) {
if (!$user instanceof InMemoryUser && !$user instanceof User) {
return;
}
if (!$user->isEnabled()) {
$ex = new DisabledException('User account is disabled.');
$ex->setUser($user);
throw $ex;
}
// @deprecated since Symfony 5.3
if (User::class === \get_class($user)) {
if (!$user->isAccountNonLocked()) {
$ex = new LockedException('User account is locked.');
$ex->setUser($user);
throw $ex;
}
if (!$user->isAccountNonExpired()) {
$ex = new AccountExpiredException('User account has expired.');
$ex->setUser($user);
throw $ex;
}
}
}
public function checkPostAuth(UserInterface $user)
{
// @deprecated since Symfony 5.3, noop in 6.0
if (User::class !== \get_class($user)) {
return;
}
if (!$user->isCredentialsNonExpired()) {
$ex = new CredentialsExpiredException('User credentials have expired.');
$ex->setUser($user);
throw $ex;
}
}
}
if (!class_exists(UserChecker::class, false)) {
class_alias(InMemoryUserChecker::class, UserChecker::class);
}

View File

@ -0,0 +1,144 @@
<?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\User;
use Symfony\Component\Security\Core\Exception\UnsupportedUserException;
use Symfony\Component\Security\Core\Exception\UserNotFoundException;
/**
* InMemoryUserProvider is a simple non persistent user provider.
*
* Useful for testing, demonstration, prototyping, and for simple needs
* (a backend with a unique admin for instance)
*
* @author Fabien Potencier <fabien@symfony.com>
*/
class InMemoryUserProvider implements UserProviderInterface
{
/**
* @var array<string, UserInterface>
*/
private $users;
/**
* 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<string, array{password?: string, enabled?: bool, roles?: list<string>}> $users An array of users
*/
public function __construct(array $users = [])
{
foreach ($users as $username => $attributes) {
$password = $attributes['password'] ?? null;
$enabled = $attributes['enabled'] ?? true;
$roles = $attributes['roles'] ?? [];
$user = new InMemoryUser($username, $password, $roles, $enabled);
$this->createUser($user);
}
}
/**
* Adds a new User to the provider.
*
* @throws \LogicException
*/
public function createUser(UserInterface $user)
{
// @deprecated since Symfony 5.3, change to $user->getUserIdentifier() in 6.0
$userIdentifier = strtolower(method_exists($user, 'getUserIdentifier') ? $user->getUserIdentifier() : $user->getUsername());
if (isset($this->users[$userIdentifier])) {
throw new \LogicException('Another user with the same username already exists.');
}
$this->users[$userIdentifier] = $user;
}
/**
* {@inheritdoc}
*/
public function loadUserByUsername(string $username)
{
trigger_deprecation('symfony/security-core', '5.3', 'Method "%s()" is deprecated, use loadUserByIdentifier() instead.', __METHOD__);
return $this->loadUserByIdentifier($username);
}
public function loadUserByIdentifier(string $identifier): UserInterface
{
$user = $this->getUser($identifier);
// @deprecated since Symfony 5.3, change to $user->getUserIdentifier() in 6.0
return new InMemoryUser(method_exists($user, 'getUserIdentifier') ? $user->getUserIdentifier() : $user->getUsername(), $user->getPassword(), $user->getRoles(), $user->isEnabled());
}
/**
* {@inheritdoc}
*/
public function refreshUser(UserInterface $user)
{
if (!$user instanceof InMemoryUser && !$user instanceof User) {
throw new UnsupportedUserException(sprintf('Instances of "%s" are not supported.', get_debug_type($user)));
}
// @deprecated since Symfony 5.3, change to $user->getUserIdentifier() in 6.0
$storedUser = $this->getUser(method_exists($user, 'getUserIdentifier') ? $user->getUserIdentifier() : $user->getUsername());
$userIdentifier = method_exists($storedUser, 'getUserIdentifier') ? $storedUser->getUserIdentifier() : $storedUser->getUsername();
// @deprecated since Symfony 5.3
if (User::class === \get_class($user)) {
if (User::class !== \get_class($storedUser)) {
$accountNonExpired = true;
$credentialsNonExpired = $storedUser->getPassword() === $user->getPassword();
$accountNonLocked = true;
} else {
$accountNonExpired = $storedUser->isAccountNonExpired();
$credentialsNonExpired = $storedUser->isCredentialsNonExpired() && $storedUser->getPassword() === $user->getPassword();
$accountNonLocked = $storedUser->isAccountNonLocked();
}
return new User($userIdentifier, $storedUser->getPassword(), $storedUser->getRoles(), $storedUser->isEnabled(), $accountNonExpired, $credentialsNonExpired, $accountNonLocked);
}
return new InMemoryUser($userIdentifier, $storedUser->getPassword(), $storedUser->getRoles(), $storedUser->isEnabled());
}
/**
* {@inheritdoc}
*/
public function supportsClass(string $class)
{
// @deprecated since Symfony 5.3
if (User::class === $class) {
return true;
}
return InMemoryUser::class == $class;
}
/**
* Returns the user by given username.
*
* @throws UserNotFoundException if user whose given username does not exist
*/
private function getUser(string $username)/*: InMemoryUser */
{
if (!isset($this->users[strtolower($username)])) {
$ex = new UserNotFoundException(sprintf('Username "%s" does not exist.', $username));
$ex->setUserIdentifier($username);
throw $ex;
}
return $this->users[strtolower($username)];
}
}

View File

@ -0,0 +1,28 @@
<?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\User;
/**
* For users that can be authenticated using a password/salt couple.
*
* Once all password hashes have been upgraded to a modern algorithm via password migrations,
* implement {@see PasswordAuthenticatedUserInterface} instead.
*
* @author Robin Chalas <robin.chalas@gmail.com>
*/
interface LegacyPasswordAuthenticatedUserInterface extends PasswordAuthenticatedUserInterface
{
/**
* Returns the salt that was originally used to hash the password.
*/
public function getSalt(): ?string;
}

View File

@ -0,0 +1,60 @@
<?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\User;
use Symfony\Component\Config\Definition\Exception\InvalidConfigurationException;
/**
* MissingUserProvider is a dummy user provider used to throw proper exception
* when a firewall requires a user provider but none was defined.
*
* @internal
*/
class MissingUserProvider implements UserProviderInterface
{
/**
* @param string $firewall the firewall missing a provider
*/
public function __construct(string $firewall)
{
throw new InvalidConfigurationException(sprintf('"%s" firewall requires a user provider but none was defined.', $firewall));
}
/**
* {@inheritdoc}
*/
public function loadUserByUsername(string $username): UserInterface
{
throw new \BadMethodCallException();
}
public function loadUserByIdentifier(string $identifier): UserInterface
{
throw new \BadMethodCallException();
}
/**
* {@inheritdoc}
*/
public function refreshUser(UserInterface $user): UserInterface
{
throw new \BadMethodCallException();
}
/**
* {@inheritdoc}
*/
public function supportsClass(string $class): bool
{
throw new \BadMethodCallException();
}
}

View File

@ -0,0 +1,28 @@
<?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\User;
/**
* For users that can be authenticated using a password.
*
* @author Robin Chalas <robin.chalas@gmail.com>
* @author Wouter de Jong <wouter@wouterj.nl>
*/
interface PasswordAuthenticatedUserInterface
{
/**
* Returns the hashed password used to authenticate the user.
*
* Usually on authentication, a plain-text password will be compared to this value.
*/
public function getPassword(): ?string;
}

View File

@ -0,0 +1,24 @@
<?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\User;
/**
* @author Nicolas Grekas <p@tchwork.com>
*
* @method void upgradePassword(PasswordAuthenticatedUserInterface|UserInterface $user, string $newHashedPassword) Upgrades the hashed password of a user, typically for using a better hash algorithm.
* This method should persist the new password in the user storage and update the $user object accordingly.
* Because you don't want your users not being able to log in, this method should be opportunistic:
* it's fine if it does nothing or if it fails without throwing any exception.
*/
interface PasswordUpgraderInterface
{
}

View File

@ -0,0 +1,218 @@
<?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\User;
/**
* User is the user implementation used by the in-memory user provider.
*
* This should not be used for anything else.
*
* @author Fabien Potencier <fabien@symfony.com>
*
* @deprecated since Symfony 5.3, use {@link InMemoryUser} instead
*/
class User implements UserInterface, PasswordAuthenticatedUserInterface, EquatableInterface
{
private $username;
private $password;
private $enabled;
private $accountNonExpired;
private $credentialsNonExpired;
private $accountNonLocked;
private $roles;
private $extraFields;
public function __construct(?string $username, ?string $password, array $roles = [], bool $enabled = true, bool $userNonExpired = true, bool $credentialsNonExpired = true, bool $userNonLocked = true, array $extraFields = [])
{
if (InMemoryUser::class !== static::class) {
trigger_deprecation('symfony/security-core', '5.3', 'The "%s" class is deprecated, use "%s" instead.', self::class, InMemoryUser::class);
}
if ('' === $username || null === $username) {
throw new \InvalidArgumentException('The username cannot be empty.');
}
$this->username = $username;
$this->password = $password;
$this->enabled = $enabled;
$this->accountNonExpired = $userNonExpired;
$this->credentialsNonExpired = $credentialsNonExpired;
$this->accountNonLocked = $userNonLocked;
$this->roles = $roles;
$this->extraFields = $extraFields;
}
public function __toString(): string
{
return $this->getUserIdentifier();
}
/**
* {@inheritdoc}
*/
public function getRoles(): array
{
return $this->roles;
}
/**
* {@inheritdoc}
*/
public function getPassword(): ?string
{
return $this->password;
}
/**
* {@inheritdoc}
*/
public function getSalt(): ?string
{
return null;
}
/**
* {@inheritdoc}
*/
public function getUsername(): string
{
trigger_deprecation('symfony/security-core', '5.3', 'Method "%s()" is deprecated, use getUserIdentifier() instead.', __METHOD__);
return $this->username;
}
/**
* Returns the identifier for this user (e.g. its username or email address).
*/
public function getUserIdentifier(): string
{
return $this->username;
}
/**
* Checks whether the user's account has expired.
*
* Internally, if this method returns false, the authentication system
* will throw an AccountExpiredException and prevent login.
*
* @see AccountExpiredException
*/
public function isAccountNonExpired(): bool
{
return $this->accountNonExpired;
}
/**
* Checks whether the user is locked.
*
* Internally, if this method returns false, the authentication system
* will throw a LockedException and prevent login.
*
* @see LockedException
*/
public function isAccountNonLocked(): bool
{
return $this->accountNonLocked;
}
/**
* Checks whether the user's credentials (password) has expired.
*
* Internally, if this method returns false, the authentication system
* will throw a CredentialsExpiredException and prevent login.
*
* @see CredentialsExpiredException
*/
public function isCredentialsNonExpired(): bool
{
return $this->credentialsNonExpired;
}
/**
* Checks whether the user is enabled.
*
* Internally, if this method returns false, the authentication system
* will throw a DisabledException and prevent login.
*
* @see DisabledException
*/
public function isEnabled(): bool
{
return $this->enabled;
}
/**
* {@inheritdoc}
*/
public function eraseCredentials()
{
}
public function getExtraFields(): array
{
return $this->extraFields;
}
/**
* {@inheritdoc}
*/
public function isEqualTo(UserInterface $user): bool
{
if (!$user instanceof self) {
return false;
}
if ($this->getPassword() !== $user->getPassword()) {
return false;
}
if ($this->getSalt() !== $user->getSalt()) {
return false;
}
$currentRoles = array_map('strval', (array) $this->getRoles());
$newRoles = array_map('strval', (array) $user->getRoles());
$rolesChanged = \count($currentRoles) !== \count($newRoles) || \count($currentRoles) !== \count(array_intersect($currentRoles, $newRoles));
if ($rolesChanged) {
return false;
}
if ($this->getUserIdentifier() !== $user->getUserIdentifier()) {
return false;
}
if (self::class === static::class) {
if ($this->isAccountNonExpired() !== $user->isAccountNonExpired()) {
return false;
}
if ($this->isAccountNonLocked() !== $user->isAccountNonLocked()) {
return false;
}
if ($this->isCredentialsNonExpired() !== $user->isCredentialsNonExpired()) {
return false;
}
}
if ($this->isEnabled() !== $user->isEnabled()) {
return false;
}
return true;
}
public function setPassword(string $password)
{
$this->password = $password;
}
}

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\Core\User;
trigger_deprecation('symfony/security-core', '5.3', 'The "%s" class is deprecated, use "%s" instead.', UserChecker::class, InMemoryUserChecker::class);
class_exists(InMemoryUserChecker::class);
if (false) {
/**
* UserChecker checks the user account flags.
*
* @author Fabien Potencier <fabien@symfony.com>
*
* @deprecated since Symfony 5.3, use {@link InMemoryUserChecker} instead
*/
class UserChecker
{
}
}

View File

@ -0,0 +1,39 @@
<?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\User;
use Symfony\Component\Security\Core\Exception\AccountStatusException;
/**
* Implement to throw AccountStatusException during the authentication process.
*
* Can be used when you want to check the account status, e.g when the account is
* disabled or blocked. This should not be used to make authentication decisions.
*
* @author Fabien Potencier <fabien@symfony.com>
*/
interface UserCheckerInterface
{
/**
* Checks the user account before authentication.
*
* @throws AccountStatusException
*/
public function checkPreAuth(UserInterface $user);
/**
* Checks the user account after authentication.
*
* @throws AccountStatusException
*/
public function checkPostAuth(UserInterface $user);
}

View File

@ -0,0 +1,88 @@
<?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\User;
/**
* Represents the interface that all user classes must implement.
*
* This interface is useful because the authentication layer can deal with
* the object through its lifecycle, using the object to get the hashed
* password (for checking against a submitted password), assigning roles
* and so on.
*
* 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.
*
* @see UserProviderInterface
*
* @method string getUserIdentifier() returns the identifier for this user (e.g. its username or email address)
*
* @author Fabien Potencier <fabien@symfony.com>
*/
interface UserInterface
{
/**
* Returns the roles granted to the user.
*
* public function getRoles()
* {
* return ['ROLE_USER'];
* }
*
* Alternatively, the roles might be stored in a ``roles`` property,
* and populated in any number of different ways when the user object
* is created.
*
* @return string[]
*/
public function getRoles();
/**
* Returns the password used to authenticate the user.
*
* This should be the hashed password. On authentication, a plain-text
* password will be hashed, and then compared to this value.
*
* This method is deprecated since Symfony 5.3, implement it from {@link PasswordAuthenticatedUserInterface} instead.
*
* @return string|null
*/
public function getPassword();
/**
* Returns the salt that was originally used to hash the password.
*
* This can return null if the password was not hashed using a salt.
*
* This method is deprecated since Symfony 5.3, implement it from {@link LegacyPasswordAuthenticatedUserInterface} instead.
*
* @return string|null
*/
public function getSalt();
/**
* Removes sensitive data from the user.
*
* This is important if, at any given point, sensitive information like
* the plain-text password is stored on this object.
*/
public function eraseCredentials();
/**
* @return string
*
* @deprecated since Symfony 5.3, use getUserIdentifier() instead
*/
public function getUsername();
}

View File

@ -0,0 +1,69 @@
<?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\User;
use Symfony\Component\Security\Core\Exception\UnsupportedUserException;
use Symfony\Component\Security\Core\Exception\UserNotFoundException;
/**
* Represents a class that loads UserInterface objects from some source for the authentication system.
*
* In a typical authentication configuration, a user identifier (e.g. a
* username or email address) credential enters the system (via form login, or
* any method). The user provider that is configured with that authentication
* method is asked to load the UserInterface object for the given identifier (via
* loadUserByIdentifier) so that the rest of the process can continue.
*
* Internally, a user provider can load users from any source (databases,
* configuration, web service). This is totally independent of how the authentication
* information is submitted or what the UserInterface object looks like.
*
* @see UserInterface
*
* @method UserInterface loadUserByIdentifier(string $identifier) loads the user for the given user identifier (e.g. username or email).
* This method must throw UserNotFoundException if the user is not found.
*
* @author Fabien Potencier <fabien@symfony.com>
*/
interface UserProviderInterface
{
/**
* Refreshes the user.
*
* It is up to the implementation to decide if the user data should be
* totally reloaded (e.g. from the database), or if the UserInterface
* object can just be merged into some internal array of users / identity
* map.
*
* @return UserInterface
*
* @throws UnsupportedUserException if the user is not supported
* @throws UserNotFoundException if the user is not found
*/
public function refreshUser(UserInterface $user);
/**
* Whether this provider supports the given user class.
*
* @return bool
*/
public function supportsClass(string $class);
/**
* @return UserInterface
*
* @throws UserNotFoundException
*
* @deprecated since Symfony 5.3, use loadUserByIdentifier() instead
*/
public function loadUserByUsername(string $username);
}