8000 Rename providerKey to firewallName for more consistent naming · symfony/symfony@b1e040f · GitHub
[go: up one dir, main page]

Skip to content

Commit b1e040f

Browse files
committed
Rename providerKey to firewallName for more consistent naming
1 parent 50224aa commit b1e040f

23 files changed

+95
-100
lines changed

src/Symfony/Bundle/SecurityBundle/DependencyInjection/Security/Factory/AnonymousFactory.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,13 +42,13 @@ public function create(ContainerBuilder $container, $id, $config, $userProvider,
4242
return [$providerId, $listenerId, $defaultEntryPoint];
4343
}
4444

45-
public function createAuthenticator(ContainerBuilder $container, string $id, array $config, string $userProviderId): string
45+
public function createAuthenticator(ContainerBuilder $container, string $firewallName, array $config, string $userProviderId): string
4646
{
4747
if (null === $config['secret']) {
4848
$config['secret'] = new Parameter('container.build_hash');
4949
}
5050

51-
$authenticatorId = 'security.authenticator.anonymous.'.$id;
51+
$authenticatorId = 'security.authenticator.anonymous.'.$firewallName;
5252
$container
5353
->setDefinition($authenticatorId, new ChildDefinition('security.authenticator.anonymous'))
5454
->replaceArgument(0, $config['secret']);

src/Symfony/Bundle/SecurityBundle/DependencyInjection/Security/Factory/AuthenticatorFactoryInterface.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,5 +25,5 @@ interface AuthenticatorFactoryInterface
2525
*
2626
* @return string|string[] The authenticator service ID(s) to be used by the firewall
2727
*/
28-
public function createAuthenticator(ContainerBuilder $container, string $id, array $config, string $userProviderId);
28+
public function createAuthenticator(ContainerBuilder $container, string $firewallName, array $config, string $userProviderId);
2929
}

src/Sym A93C fony/Bundle/SecurityBundle/DependencyInjection/Security/Factory/CustomAuthenticatorFactory.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public function addConfiguration(NodeDefinition $builder)
4949
;
5050
}
5151

52-
public function createAuthenticator(ContainerBuilder $container, string $id, array $config, string $userProviderId): array
52+
public function createAuthenticator(ContainerBuilder $container, string $firewallName, array $config, string $userProviderId): array
5353
{
5454
return $config['services'];
5555
}

src/Symfony/Bundle/SecurityBundle/DependencyInjection/Security/Factory/FormLoginFactory.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -103,19 +103,19 @@ public function createEntryPoint(ContainerBuilder $container, string $id, array
103103
return $entryPointId;
104104
}
105105

106-
public function createAuthenticator(ContainerBuilder $container, string $id, array $config, string $userProviderId): string
106+
public function createAuthenticator(ContainerBuilder $container, string $firewallName, array $config, string $userProviderId): string
107107
{
108108
if (isset($config['csrf_token_generator'])) {
109109
throw new InvalidConfigurationException('The "csrf_token_generator" option of "form_login" is only available when "security.enable_authenticator_manager" is set to "false", use "enable_csrf" instead.');
110110
}
111111

112-
$authenticatorId = 'security.authenticator.form_login.'.$id;
112+
$authenticatorId = 'security.authenticator.form_login.'.$firewallName;
113113
$options = array_intersect_key($config, $this->options);
114114
$container
115115
->setDefinition($authenticatorId, new ChildDefinition('security.authenticator.form_login'))
116116
->replaceArgument(1, new Reference($userProviderId))
117-
->replaceArgument(2, new Reference($this->createAuthenticationSuccessHandler($container, $id, $config)))
118-
->replaceArgument(3, new Reference($this->createAuthenticationFailureHandler($container, $id, $config)))
117+
->replaceArgument(2, new Reference($this->createAuthenticationSuccessHandler($container, $firewallName, $config)))
118+
->replaceArgument(3, new Reference($this->createAuthenticationFailureHandler($container, $firewallName, $config)))
119119
->replaceArgument(4, $options);
120120

121121
return $authenticatorId;

src/Symfony/Bundle/SecurityBundle/DependencyInjection/Security/Factory/HttpBasicFactory.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,9 @@ public function create(ContainerBuilder $container, string $id, array $config, s
4646
return [$provider, $listenerId, $entryPointId];
4747
}
4848

49-
public function createAuthenticator(ContainerBuilder $container, string $id, array $config, string $userProviderId): string
49+
public function createAuthenticator(ContainerBuilder $container, string $firewallName, array $config, string $userProviderId): string
5050
{
51-
$authenticatorId = 'security.authenticator.http_basic.'.$id;
51+
$authenticatorId = 'security.authenticator.http_basic.'.$firewallName;
5252
$container
5353
->setDefinition($authenticatorId, new ChildDefinition('security.authenticator.http_basic'))
5454
->replaceArgument(0, $config['realm'])

src/Symfony/Bundle/SecurityBundle/DependencyInjection/Security/Factory/JsonLoginFactory.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -97,15 +97,15 @@ protected function createListener(ContainerBuilder $container, string $id, array
9797
return $listenerId;
9898
}
9999

100-
public function createAuthenticator(ContainerBuilder $container, string $id, array $config, string $userProviderId)
100+
public function createAuthenticator(ContainerBuilder $container, string $firewallName, array $config, string $userProviderId)
101101
{
102-
$authenticatorId = 'security.authenticator.json_login.'.$id;
102+
$authenticatorId = 'security.authenticator.json_login.'.$firewallName;
103103
$options = array_intersect_key($config, $this->options);
104104
$container
105105
->setDefinition($authenticatorId, new ChildDefinition('security.authenticator.json_login'))
106106
->replaceArgument(1, new Reference($userProviderId))
107-
->replaceArgument(2, isset($config['success_handler']) ? new Reference($this->createAuthenticationSuccessHandler($container, $id, $config)) : null)
108-
->replaceArgument(3, isset($config['failure_handler']) ? new Reference($this->createAuthenticationFailureHandler($container, $id, $config)) : null)
107+
->replaceArgument(2, isset($config['success_handler']) ? new Reference($this->createAuthenticationSuccessHandler($container, $firewallName, $config)) : null)
108+
->replaceArgument(3, isset($config['failure_handler']) ? new Reference($this->createAuthenticationFailureHandler($container, $firewallName, $config)) : null)
109109
->replaceArgument(4, $options);
110110

111111
return $authenticatorId;

src/Symfony/Bundle/SecurityBundle/DependencyInjection/Security/Factory/RememberMeFactory.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -89,19 +89,19 @@ public function create(ContainerBuilder $container, string $id, array $config, ?
8989
return [$authProviderId, $listenerId, $defaultEntryPoint];
9090
}
9191

92-
public function createAuthenticator(ContainerBuilder $container, string $id, array $config, string $userProviderId): string
92+
public function createAuthenticator(ContainerBuilder $container, string $firewallName, array $config, string $userProviderId): string
9393
{
94-
$templateId = $this->generateRememberMeServicesTemplateId($config, $id);
95-
$rememberMeServicesId = $templateId.'.'.$id;
94+
$templateId = $this->generateRememberMeServicesTemplateId($config, $firewallName);
95+
$rememberMeServicesId = $templateId.'.'.$firewallName;
9696

9797
// create remember me services (which manage the remember me cookies)
98-
$this->createRememberMeServices($container, $id, $templateId, [new Reference($userProviderId)], $config);
98+
$this->createRememberMeServices($container, $firewallName, $templateId, [new Reference($userProviderId)], $config);
9999

100100
// create remember me listener (which executes the remember me services for other authenticators and logout)
101-
$this->createRememberMeListener($container, $id, $rememberMeServicesId);
101+
$this->createRememberMeListener($container, $firewallName, $rememberMeServicesId);
102102

103103
// create remember me authenticator (which re-authenticates the user based on the remember me cookie)
104-
$authenticatorId = 'security.authenticator.remember_me.'.$id;
104+
$authenticatorId = 'security.authenticator.remember_me.'.$firewallName;
105105
$container
106106
->setDefinition($authenticatorId, new ChildDefinition('security.authenticator.remember_me'))
107107
->replaceArgument(0, new Reference($rememberMeServicesId))

src/Symfony/Bundle/SecurityBundle/DependencyInjection/Security/Factory/RemoteUserFactory.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,9 @@ public function create(ContainerBuilder $container, string $id, array $config, s
4343
return [$providerId, $listenerId, $defaultEntryPoint];
4444
}
4545

46-
public function createAuthenticator(ContainerBuilder $container, string $id, array $config, string $userProviderId)
46+
public function createAuthenticator(ContainerBuilder $container, string $firewallName, array $config, string $userProviderId)
4747
{
48-
$authenticatorId = 'security.authenticator.remote_user.'.$id;
48+
$authenticatorId = 'security.authenticator.remote_user.'.$firewallName;
4949
$container
5050
->setDefinition($authenticatorId, new ChildDefinition('security.authenticator.remote_user'))
5151
->replaceArgument(0, new Reference($userProviderId))

src/Symfony/Bundle/SecurityBundle/DependencyInjection/Security/Factory/X509Factory.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,9 @@ public function create(ContainerBuilder $container, string $id, array $config, s
4444
return [$providerId, $listenerId, $defaultEntryPoint];
4545
}
4646

47-
public function createAuthenticator(ContainerBuilder $container, string $id, array $config, string $userProviderId)
47+
public function createAuthenticator(ContainerBuilder $container, string $firewallName, array $config, string $userProviderId)
4848
{
49-
$authenticatorId = 'security.authenticator.x509.'.$id;
49+
$authenticatorId = 'security.authenticator.x509.'.$firewallName;
5050
$container
5151
->setDefinition($authenticatorId, new ChildDefinition('security.authenticator.x509'))
5252
->replaceArgument(0, new Reference($userProviderId))

src/Symfony/Bundle/SecurityBundle/DependencyInjection/SecurityExtension.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,7 @@ private function createFirewalls(array $config, ContainerBuilder $container)
286286
// add authentication providers to authentication manager
287287
$authenticationProviders = array_map(function ($id) {
288288
return new Reference($id);
289-
}, array_unique($authenticationProviders));
289+
}, array_values(array_unique($authenticationProviders)));
290290

291291
$container
292292
->getDefinition('security.authentication.manager')
@@ -439,9 +439,9 @@ private function createFirewall(ContainerBuilder $container, string $id, array $
439439
$firewallAuthenticationProviders = [];
440440
list($authListeners, $defaultEntryPoint) = $this->createAuthenticationListeners($container, $id, $firewall, $firewallAuthenticationProviders, $defaultProvider, $providerIds, $configuredEntryPoint, $contextListenerId);
441441

442-
$authenticationProviders = array_merge($authenticationProviders, $firewallAuthenticationProviders);
443-
444-
if ($this->authenticatorManagerEnabled) {
442+
if (!$this->authenticatorManagerEnabled) {
443+
$authenticationProviders = array_merge($authenticationProviders, $firewallAuthenticationProviders);
444+
} else {
445445
// authenticator manager
446446
$authenticators = array_map(function ($id) {
447447
return new Reference($id);
@@ -535,10 +535,10 @@ private function createAuthenticationListeners(ContainerBuilder $container, stri
535535
$authenticators = $factory->createAuthenticator($container, $id, $firewall[$key], $userProvider);
536536
if (\is_array($authenticators)) {
537537
foreach ($authenticators as $i => $authenticator) {
538-
$authenticationProviders[$id.'_'.$key.$i] = $authenticator;
538+
$authenticationProviders[] = $authenticator;
539539
}
540540
} else {
541-
$authenticationProviders[$id.'_'.$key] = $authenticators;
541+
$authenticationProviders[] = $authenticators;
542542
}
543543

544544
if ($factory instanceof EntryPointFactoryInterface) {
@@ -548,7 +548,7 @@ private function createAuthenticationListeners(ContainerBuilder $container, stri
548548
list($provider, $listenerId, $defaultEntryPoint) = $factory->create($container, $id, $firewall[$key], $userProvider, $defaultEntryPoint);
549549

550550
$listeners[] = new Reference($listenerId);
551-
$authenticationProviders[$id.'_'.$key] = $provider;
551+
$authenticationProviders[] = $provider;
552552
}
553553
$hasListeners = true;
554554
}

0 commit comments

Comments
 (0)
0