Skip to content

Commit

Permalink
minor #34739 [Security] Make remember-me user providers lazy (chalasr)
Browse files Browse the repository at this point in the history
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
-------

bea7456 [Security} Make remember-me user providers lazy
  • Loading branch information
chalasr committed Dec 6, 2019
2 parents c732122 + bea7456 commit 0d2f411
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
Expand Up @@ -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;
Expand Down Expand Up @@ -104,7 +105,7 @@ public function create(ContainerBuilder $container, string $id, array $config, ?
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;
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Bundle/SecurityBundle/composer.json
Expand Up @@ -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",
Expand Down
Expand Up @@ -47,14 +47,17 @@ 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.');
}
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.');
}
Expand Down

0 comments on commit 0d2f411

Please sign in to comment.