Skip to content

Commit

Permalink
[SecurityBundle] Remove last usages of tag security.remember_me_aware
Browse files Browse the repository at this point in the history
  • Loading branch information
alamirault authored and nicolas-grekas committed Jun 20, 2023
1 parent 43faa9b commit ee02083
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 19 deletions.
9 changes: 0 additions & 9 deletions DependencyInjection/Security/Factory/RememberMeFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -111,15 +111,6 @@ public function createAuthenticator(ContainerBuilder $container, string $firewal
->replaceArgument(3, $config['name'] ?? $this->options['name'])
;

foreach ($container->findTaggedServiceIds('security.remember_me_aware') as $serviceId => $attributes) {
// register ContextListener
if (str_starts_with($serviceId, 'security.context_listener')) {
continue;
}

throw new \LogicException(sprintf('Symfony Authenticator Security dropped support for the "security.remember_me_aware" tag, service "%s" will no longer work as expected.', $serviceId));
}

return $authenticatorId;
}

Expand Down
15 changes: 5 additions & 10 deletions DependencyInjection/SecurityExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -417,11 +417,10 @@ private function createFirewall(ContainerBuilder $container, string $id, array $
$listeners[] = new Reference('security.channel_listener');

$contextKey = null;
$contextListenerId = null;
// Context serializer listener
if (false === $firewall['stateless']) {
$contextKey = $firewall['context'] ?? $id;
$listeners[] = new Reference($contextListenerId = $this->createContextListener($container, $contextKey, $firewallEventDispatcherId));
$listeners[] = new Reference($this->createContextListener($container, $contextKey, $firewallEventDispatcherId));
$sessionStrategyId = 'security.authentication.session_strategy';

$container
Expand Down Expand Up @@ -490,7 +489,7 @@ private function createFirewall(ContainerBuilder $container, string $id, array $

// Authentication listeners
$firewallAuthenticationProviders = [];
[$authListeners, $defaultEntryPoint] = $this->createAuthenticationListeners($container, $id, $firewall, $firewallAuthenticationProviders, $defaultProvider, $providerIds, $configuredEntryPoint, $contextListenerId);
[$authListeners, $defaultEntryPoint] = $this->createAuthenticationListeners($container, $id, $firewall, $firewallAuthenticationProviders, $defaultProvider, $providerIds, $configuredEntryPoint);

// $configuredEntryPoint is resolved into a service ID and stored in $defaultEntryPoint
$configuredEntryPoint = $defaultEntryPoint;
Expand Down Expand Up @@ -596,7 +595,7 @@ private function createContextListener(ContainerBuilder $container, string $cont
return $this->contextListeners[$contextKey] = $listenerId;
}

private function createAuthenticationListeners(ContainerBuilder $container, string $id, array $firewall, array &$authenticationProviders, ?string $defaultProvider, array $providerIds, ?string $defaultEntryPoint, string $contextListenerId = null)
private function createAuthenticationListeners(ContainerBuilder $container, string $id, array $firewall, array &$authenticationProviders, ?string $defaultProvider, array $providerIds, ?string $defaultEntryPoint)
{
$listeners = [];
$entryPoints = [];
Expand All @@ -605,7 +604,7 @@ private function createAuthenticationListeners(ContainerBuilder $container, stri
$key = str_replace('-', '_', $factory->getKey());

if (isset($firewall[$key])) {
$userProvider = $this->getUserProvider($container, $id, $firewall, $key, $defaultProvider, $providerIds, $contextListenerId);
$userProvider = $this->getUserProvider($container, $id, $firewall, $key, $defaultProvider, $providerIds);

if (!$factory instanceof AuthenticatorFactoryInterface) {
throw new InvalidConfigurationException(sprintf('Authenticator factory "%s" ("%s") must implement "%s".', get_debug_type($factory), $key, AuthenticatorFactoryInterface::class));
Expand Down Expand Up @@ -637,7 +636,7 @@ private function createAuthenticationListeners(ContainerBuilder $container, stri
return [$listeners, $defaultEntryPoint];
}

private function getUserProvider(ContainerBuilder $container, string $id, array $firewall, string $factoryKey, ?string $defaultProvider, array $providerIds, ?string $contextListenerId): string
private function getUserProvider(ContainerBuilder $container, string $id, array $firewall, string $factoryKey, ?string $defaultProvider, array $providerIds): string
{
if (isset($firewall[$factoryKey]['provider'])) {
if (!isset($providerIds[$normalizedName = str_replace('-', '_', $firewall[$factoryKey]['provider'])])) {
Expand All @@ -647,10 +646,6 @@ private function getUserProvider(ContainerBuilder $container, string $id, array
return $providerIds[$normalizedName];
}

if ('remember_me' === $factoryKey && $contextListenerId) {
$container->getDefinition($contextListenerId)->addTag('security.remember_me_aware', ['id' => $id, 'provider' => 'none']);
}

if ($defaultProvider) {
return $defaultProvider;
}
Expand Down

0 comments on commit ee02083

Please sign in to comment.