minor #34739 [Security] Make remember-me user providers lazy (chalasr)
This PR was merged into the 5.1-dev branch.
Discussion
----------
[Security] Make remember-me user providers lazy
| Q | A
| ------------- | ---
| Branch? | 4.4
| Bug fix? | no
| New feature? | no
| Deprecations? | no
| Tickets | -
| License | MIT
| Doc PR | -
As everywhere else
Commits
-------
bea74560e1
[Security} Make remember-me user providers lazy
This commit is contained in:
commit
0d2f4111d3
@ -12,6 +12,7 @@
|
||||
namespace Symfony\Bundle\SecurityBundle\DependencyInjection\Security\Factory;
|
||||
|
||||
use Symfony\Component\Config\Definition\Builder\NodeDefinition;
|
||||
use Symfony\Component\DependencyInjection\Argument\IteratorArgument;
|
||||
use Symfony\Component\DependencyInjection\ChildDefinition;
|
||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||
use Symfony\Component\DependencyInjection\Reference;
|
||||
@ -104,7 +105,7 @@ class RememberMeFactory implements SecurityFactoryInterface
|
||||
throw new \RuntimeException('You must configure at least one remember-me aware listener (such as form-login) for each firewall that has remember-me enabled.');
|
||||
}
|
||||
|
||||
$rememberMeServices->replaceArgument(0, array_unique($userProviders));
|
||||
$rememberMeServices->replaceArgument(0, new IteratorArgument(array_unique($userProviders)));
|
||||
|
||||
// remember-me listener
|
||||
$listenerId = 'security.authentication.listener.rememberme.'.$id;
|
||||
|
@ -24,7 +24,7 @@
|
||||
"symfony/security-core": "^4.4|^5.0",
|
||||
"symfony/security-csrf": "^4.4|^5.0",
|
||||
"symfony/security-guard": "^4.4|^5.0",
|
||||
"symfony/security-http": "^4.4.1|^5.0.1"
|
||||
"symfony/security-http": "^5.1"
|
||||
},
|
||||
"require-dev": {
|
||||
"doctrine/doctrine-bundle": "^1.5|^2.0",
|
||||
|
@ -47,7 +47,7 @@ abstract class AbstractRememberMeServices implements RememberMeServicesInterface
|
||||
/**
|
||||
* @throws \InvalidArgumentException
|
||||
*/
|
||||
public function __construct(array $userProviders, string $secret, string $providerKey, array $options = [], LoggerInterface $logger = null)
|
||||
public function __construct(iterable $userProviders, string $secret, string $providerKey, array $options = [], LoggerInterface $logger = null)
|
||||
{
|
||||
if (empty($secret)) {
|
||||
throw new \InvalidArgumentException('$secret must not be empty.');
|
||||
@ -55,6 +55,9 @@ abstract class AbstractRememberMeServices implements RememberMeServicesInterface
|
||||
if (empty($providerKey)) {
|
||||
throw new \InvalidArgumentException('$providerKey must not be empty.');
|
||||
}
|
||||
if (!\is_array($userProviders) && !$userProviders instanceof \Countable) {
|
||||
$userProviders = iterator_to_array($userProviders, false);
|
||||
}
|
||||
if (0 === \count($userProviders)) {
|
||||
throw new \InvalidArgumentException('You must provide at least one user provider.');
|
||||
}
|
||||
|
Reference in New Issue
Block a user