Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 7859977

Browse files
committed
Removed all mentions of 'guard' in the new system
This to remove confusion between the new system and Guard. When using the new system, guard should not be installed. Guard did however influence the idea behind the new system. Thus keeping the mentions of "guard" makes it confusing to use the new system.
1 parent 999ec27 commit 7859977

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+419
-316
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ public function getConfigTreeBuilder()
7373
->booleanNode('hide_user_not_found')->defaultTrue()->end()
7474
->booleanNode('always_authenticate_before_granting')->defaultFalse()->end()
7575
->booleanNode('erase_credentials')->defaultTrue()->end()
76-
->booleanNode('guard_authentication_manager')->defaultFalse()->end()
76+
->booleanNode('enable_authenticator_manager')->defaultFalse()->info('Enables the new Symfony Security system based on Authenticators, all used authenticators must support this before enabling this.')->end()
7777
->arrayNode('access_decision_manager')
7878
->addDefaultsIfNotSet()
7979
->children()

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
/**
2020
* @author Wouter de Jong <[email protected]>
2121
*/
22-
class AnonymousFactory implements SecurityFactoryInterface, GuardFactoryInterface
22+
class AnonymousFactory implements SecurityFactoryInterface, AuthenticatorFactoryInterface
2323
{
2424
public function create(ContainerBuilder $container, $id, $config, $userProvider, $defaultEntryPoint)
2525
{
@@ -42,7 +42,7 @@ public function create(ContainerBuilder $container, $id, $config, $userProvider,
4242
return [$providerId, $listenerId, $defaultEntryPoint];
4343
}
4444

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

src/Symfony/Bundle/SecurityBundle/DependencyInjection/Security/Factory/GuardFactoryInterface.php renamed to src/Symfony/Bundle/SecurityBundle/DependencyInjection/Security/Factory/AuthenticatorFactoryInterface.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,12 @@
1818
*
1919
* @experimental in 5.1
2020
*/
21-
interface GuardFactoryInterface
21+
interface AuthenticatorFactoryInterface
2222
{
2323
/**
24-
* Creates the Guard service(s) for the provided configuration.
24+
* Creates the authenticator service(s) for the provided configuration.
2525
*
26-
* @return string|string[] The Guard service ID(s) to be used by the firewall
26+
* @return string|string[] The authenticator service ID(s) to be used by the firewall
2727
*/
28-
public function createGuard(ContainerBuilder $container, string $id, array $config, ?string $userProviderId);
28+
public function createAuthenticator(ContainerBuilder $container, string $id, array $config, ?string $userProviderId);
2929
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
* @author Fabien Potencier <[email protected]>
2323
* @author Johannes M. Schmitt <[email protected]>
2424
*/
25-
class FormLoginFactory extends AbstractFactory implements GuardFactoryInterface, EntryPointFactoryInterface
25+
class FormLoginFactory extends AbstractFactory implements AuthenticatorFactoryInterface, EntryPointFactoryInterface
2626
{
2727
public function __construct()
2828
{
@@ -97,7 +97,7 @@ public function createEntryPoint(ContainerBuilder $container, string $id, array
9797
return $entryPointId;
9898
}
9999

100-
public function createGuard(ContainerBuilder $container, string $id, array $config, ?string $userProviderId): string
100+
public function createAuthenticator(ContainerBuilder $container, string $id, array $config, ?string $userProviderId): string
101101
{
102102
$authenticatorId = 'security.authenticator.form_login.'.$id;
103103
$defaultOptions = array_merge($this->defaultSuccessHandlerOptions, $this->options);

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
*
2222
* @author Fabien Potencier <[email protected]>
2323
*/
24-
class HttpBasicFactory implements SecurityFactoryInterface, GuardFactoryInterface
24+
class HttpBasicFactory implements SecurityFactoryInterface, AuthenticatorFactoryInterface
2525
{
2626
public function create(ContainerBuilder $container, string $id, array $config, string $userProvider, ?string $defaultEntryPoint)
2727
{
@@ -46,7 +46,7 @@ public function create(ContainerBuilder $container, string $id, array $config, s
4646
return [$provider, $listenerId, $entryPointId];
4747
}
4848

49-
public function createGuard(ContainerBuilder $container, string $id, array $config, ?string $userProviderId): string
49+
public function createAuthenticator(ContainerBuilder $container, string $id, array $config, ?string $userProviderId): string
5050
{
5151
$authenticatorId = 'security.authenticator.http_basic.'.$id;
5252
$container

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

Lines changed: 21 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111

1212
namespace Symfony\Bundle\SecurityBundle\DependencyInjection;
1313

14+
use Symfony\Bundle\SecurityBundle\DependencyInjection\Security\Factory\AuthenticatorFactoryInterface;
1415
use Symfony\Bundle\SecurityBundle\DependencyInjection\Security\Factory\EntryPointFactoryInterface;
15-
use Symfony\Bundle\SecurityBundle\DependencyInjection\Security\Factory\GuardFactoryInterface;
1616
use Symfony\Bundle\SecurityBundle\DependencyInjection\Security\Factory\RememberMeFactory;
1717
use Symfony\Bundle\SecurityBundle\DependencyInjection\Security\Factory\SecurityFactoryInterface;
1818
use Symfony\Bundle\SecurityBundle\DependencyInjection\Security\UserProvider\UserProviderFactoryInterface;
@@ -54,7 +54,7 @@ class SecurityExtension extends Extension implements PrependExtensionInterface
5454
private $userProviderFactories = [];
5555
private $statelessFirewallKeys = [];
5656

57-
private $guardAuthenticationManagerEnabled = false;
57+
private $authenticatorManagerEnabled = false;
5858

5959
public function __construct()
6060
{
@@ -139,7 +139,7 @@ public function load(array $configs, ContainerBuilder $container)
139139
$container->setParameter('security.access.always_authenticate_before_granting', $config['always_authenticate_before_granting']);
140140
$container->setParameter('security.authentication.hide_user_not_found', $config['hide_user_not_found']);
141141

142-
if ($this->guardAuthenticationManagerEnabled = $config['guard_authentication_manager']) {
142+
if ($this->authenticatorManagerEnabled = $config['enable_authenticator_manager']) {
143143
$loader->load('authenticators.xml');
144144
}
145145

@@ -150,6 +150,11 @@ public function load(array $configs, ContainerBuilder $container)
150150
$container->getDefinition('security.authentication.guard_handler')
151151
->replaceArgument(2, $this->statelessFirewallKeys);
152152

153+
if ($this->authenticatorManagerEnabled) {
154+
$container->getDefinition('security.authenticator_handler')
155+
->replaceArgument(2, $this->statelessFirewallKeys);
156+
}
157+
153158
if ($config['encoders']) {
154159
$this->createEncoders($config['encoders'], $container);
155160
}
@@ -267,8 +272,8 @@ private function createFirewalls(array $config, ContainerBuilder $container)
267272
return new Reference($id);
268273
}, array_unique($authenticationProviders));
269274
$authenticationManagerId = 'security.authentication.manager.provider';
270-
if ($this->guardAuthenticationManagerEnabled) {
271-
$authenticationManagerId = 'security.authentication.manager.guard';
275+
if ($this->authenticatorManagerEnabled) {
276+
$authenticationManagerId = 'security.authentication.manager.authenticator';
272277
$container->setAlias('security.authentication.manager', new Alias($authenticationManagerId));
273278
}
274279
$container
@@ -418,7 +423,7 @@ private function createFirewall(ContainerBuilder $container, string $id, array $
418423
// Determine default entry point
419424
$configuredEntryPoint = isset($firewall['entry_point']) ? $firewall['entry_point'] : null;
420425

421-
if ($this->guardAuthenticationManagerEnabled) {
426+
if ($this->authenticatorManagerEnabled) {
422427
// Remember me listener (must be before calling createAuthenticationListeners() to inject remember me services)
423428
$container
424429
->setDefinition('security.listener.remember_me.'.$id, new ChildDefinition('security.listener.remember_me'))
@@ -434,24 +439,24 @@ private function createFirewall(ContainerBuilder $container, string $id, array $
434439

435440
$authenticationProviders = array_merge($authenticationProviders, $firewallAuthenticationProviders);
436441

437-
if ($this->guardAuthenticationManagerEnabled) {
438-
// guard authentication manager listener
442+
if ($this->authenticatorManagerEnabled) {
443+
// authenticator manager listener
439444
$container
440-
->setDefinition('security.firewall.guard.'.$id.'.locator', new ChildDefinition('security.firewall.guard.locator'))
445+
->setDefinition('security.firewall.authenticator.'.$id.'.locator', new ChildDefinition('security.firewall.authenticator.locator'))
441446
->setArguments([array_map(function ($id) {
442447
return new Reference($id);
443448
}, $firewallAuthenticationProviders)])
444449
->addTag('container.service_locator')
445450
;
446451

447452
$container
448-
->setDefinition('security.firewall.guard.'.$id, new ChildDefinition('security.firewall.guard'))
449-
->replaceArgument(2, new Reference('security.firewall.guard.'.$id.'.locator'))
453+
->setDefinition('security.firewall.authenticator.'.$id, new ChildDefinition('security.firewall.authenticator'))
454+
->replaceArgument(2, new Reference('security.firewall.authenticator.'.$id.'.locator'))
450455
->replaceArgument(3, $id)
451456
->addTag('kernel.event_listener', ['event' => KernelEvents::REQUEST])
452457
;
453458

454-
$listeners[] = new Reference('security.firewall.guard.'.$id);
459+
$listeners[] = new Reference('security.firewall.authenticator.'.$id);
455460
}
456461

457462
$config->replaceArgument(7, $configuredEntryPoint ?: $defaultEntryPoint);
@@ -515,12 +520,12 @@ private function createAuthenticationListeners(ContainerBuilder $container, stri
515520
if (isset($firewall[$key])) {
516521
$userProvider = $this->getUserProvider($container, $id, $firewall, $key, $defaultProvider, $providerIds, $contextListenerId);
517522

518-
if ($this->guardAuthenticationManagerEnabled) {
519-
if (!$factory instanceof GuardFactoryInterface) {
520-
throw new InvalidConfigurationException(sprintf('Cannot configure GuardAuthenticationManager as %s authentication does not support it, set security.guard_authentication_manager to `false`.', $key));
523+
if ($this->authenticatorManagerEnabled) {
524+
if (!$factory instanceof AuthenticatorFactoryInterface) {
525+
throw new InvalidConfigurationException(sprintf('Cannot configure AuthenticatorManager as "%s" authentication does not support it, set "security.enable_authenticator_manager" to `false`.', $key));
521526
}
522527

523-
$authenticators = $factory->createGuard($container, $id, $firewall[$key], $userProvider);
528+
$authenticators = $factory->createAuthenticator($container, $id, $firewall[$key], $userProvider);
524529
if (\is_array($authenticators)) {
525530
foreach ($authenticators as $i => $authenticator) {
526531
$authenticationProviders[$id.'_'.$key.$i] = $authenticator;

src/Symfony/Bundle/SecurityBundle/EventListener/LazyGuardManagerListener.php renamed to src/Symfony/Bundle/SecurityBundle/EventListener/LazyAuthenticatorManagerListener.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,32 +16,32 @@
1616
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
1717
use Symfony\Component\HttpFoundation\Request;
1818
use Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface;
19-
use Symfony\Component\Security\Guard\GuardAuthenticatorHandler;
20-
use Symfony\Component\Security\Http\Firewall\GuardManagerListener;
19+
use Symfony\Component\Security\Http\Authentication\AuthenticatorHandler;
20+
use Symfony\Component\Security\Http\Firewall\AuthenticatorManagerListener;
2121

2222
/**
2323
* @author Wouter de Jong <[email protected]>
2424
*
2525
* @experimental in 5.1
2626
*/
27-
class LazyGuardManagerListener extends GuardManagerListener
27+
class LazyAuthenticatorManagerListener extends AuthenticatorManagerListener
2828
{
2929
private $guardLocator;
3030

3131
public function __construct(
3232
AuthenticationManagerInterface $authenticationManager,
33-
GuardAuthenticatorHandler $guardHandler,
33+
AuthenticatorHandler $authenticatorHandler,
3434
ServiceLocator $guardLocator,
3535
string $providerKey,
3636
EventDispatcherInterface $eventDispatcher,
3737
?LoggerInterface $logger = null
3838
) {
39-
parent::__construct($authenticationManager, $guardHandler, [], $providerKey, $eventDispatcher, $logger);
39+
parent::__construct($authenticationManager, $authenticatorHandler, [], $providerKey, $eventDispatcher, $logger);
4040

4141
$this->guardLocator = $guardLocator;
4242
}
4343

44-
protected function getSupportingGuardAuthenticators(Request $request): array
44+
protected function getSupportingAuthenticators(Request $request): array
4545
{
4646
$guardAuthenticators = [];
4747
foreach ($this->guardLocator->getProvidedServices() as $key => $type) {

src/Symfony/Bundle/SecurityBundle/Resources/config/authenticators.xml

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,28 @@
44
xsi:schemaLocation="http://symfony.com/schema/dic/services https://symfony.com/schema/dic/services/services-1.0.xsd">
55

66
<services>
7-
<service id="security.firewall.guard.locator"
7+
<service id="security.authenticator_handler"
8+
class="Symfony\Component\Security\Http\Authentication\AuthenticatorHandler"
9+
>
10+
<argument type="service" id="security.token_storage" />
11+
<argument type="service" id="event_dispatcher" on-invalid="null" />
12+
<argument /> <!-- stateless firewall keys -->
13+
<call method="setSessionAuthenticationStrategy">
14+
<argument type="service" id="security.authentication.session_strategy" />
15+
</call>
16+
</service>
17+
18+
<service id="security.firewall.authenticator.locator"
819
class="Symfony\Component\DependencyInjection\ServiceLocator"
920
abstract="true" />
1021

11-
<service id="security.firewall.guard"
12-
class="Symfony\Bundle\SecurityBundle\EventListener\LazyGuardManagerListener"
22+
<service id="security.firewall.authenticator"
23+
class="Symfony\Bundle\SecurityBundle\EventListener\LazyAuthenticatorManagerListener"
1324
abstract="true">
1425
<tag name="monolog.logger" channel="security" />
1526
<argument type="service" id="security.authentication.manager" />
16-
<argument type="service" id="security.authentication.guard_handler" />
17-
<argument/> <!-- guard authenticator locator -->
27+
<argument type="service" id="security.authenticator_handler" />
28+
<argument/> <!-- authenticator locator -->
1829
<argument/> <!-- provider key -->
1930
<argument type="service" id="event_dispatcher" />
2031
<argument type="service" id="logger" on-invalid="null" />
@@ -48,7 +59,7 @@
4859
<!-- Authenticators -->
4960

5061
<service id="security.authenticator.http_basic"
51-
class="Symfony\Component\Security\Http\Authentication\Authenticator\HttpBasicAuthenticator"
62+
class="Symfony\Component\Security\Http\Authenticator\HttpBasicAuthenticator"
5263
abstract="true">
5364
<argument type="abstract">realm name</argument>
5465
<argument type="abstract">user provider</argument>
@@ -57,7 +68,7 @@
5768
</service>
5869

5970
<service id="security.authenticator.form_login"
60-
class="Symfony\Component\Security\Http\Authentication\Authenticator\FormLoginAuthenticator"
71+
class="Symfony\Component\Security\Http\Authenticator\FormLoginAuthenticator"
6172
abstract="true">
6273
<argument type="service" id="security.http_utils" />
6374
<argument /> <!-- csrf token generator -->
@@ -66,7 +77,7 @@
6677
</service>
6778

6879
<service id="security.authenticator.anonymous"
69-
class="Symfony\Component\Security\Http\Authentication\Authenticator\AnonymousAuthenticator"
80+
class="Symfony\Component\Security\Http\Authenticator\AnonymousAuthenticator"
7081
abstract="true">
7182
<argument type="abstract">secret</argument>
7283
<argument type="service" id="security.token_storage" />

src/Symfony/Bundle/SecurityBundle/Resources/config/guard.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
<defaults public="false" />
99

1010
<service id="security.authentication.guard_handler"
11-
class="Symfony\Component\Security\Guard\GuardAuthenticatorHandler"
11+
class="Symfony\Component\Security\Guard\GuardHandler"
1212
>
1313
<argument type="service" id="security.token_storage" />
1414
<argument type="service" id="event_dispatcher" on-invalid="null" />
@@ -17,8 +17,8 @@
1717
<argument type="service" id="security.authentication.session_strategy" />
1818
</call>
1919
</service>
20-
21-
<service id="Symfony\Component\Security\Guard\GuardAuthenticatorHandler" alias="security.authentication.guard_handler" />
20+
21+
<service id="AuthenticatorHandler" alias="security.authentication.guard_handler" />
2222

2323
<!-- See GuardAuthenticationFactory -->
2424
<service id="security.authentication.provider.guard"

src/Symfony/Bundle/SecurityBundle/Resources/config/security.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,8 @@
5252
<argument type="service" id="event_dispatcher" />
5353
</call>
5454
</service>
55-
<service id="security.authentication.manager.guard" class="Symfony\Component\Security\Http\Authentication\GuardAuthenticationManager">
56-
<argument /> <!-- guard authenticators -->
55+
<service id="security.authentication.manager.authenticator" class="Symfony\Component\Security\Http\Authentication\AuthenticatorManager">
56+
<argument /> <!-- authenticators -->
5757
<argument type="service" id="event_dispatcher" />
5858
<argument>%security.authentication.manager.erase_credentials%</argument>
5959
<call method="setEventDispatcher">

0 commit comments

Comments
 (0)