8000 [Security\Core] Fix NoopAuthenticationManager::authenticate() return … · symfony/symfony@b05da72 · GitHub
[go: up one dir, main page]

Skip to content

Commit b05da72

Browse files
chalasrnicolas-grekas
authored andcommitted
[Security\Core] Fix NoopAuthenticationManager::authenticate() return value
1 parent a73523b commit b05da72

File tree

3 files changed

+20
-0
lines changed

3 files changed

+20
-0
lines changed

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,10 @@ public function load(array $configs, ContainerBuilder $container)
111111
$loader->load('security_rememberme.xml');
112112

113113
if ($this->authenticatorManagerEnabled = $config['enable_authenticator_manager']) {
114+
if ($config['always_authenticate_before_granting']) {
115+
throw new InvalidConfigurationException('The security option "always_authenticate_before_granting" cannot be used when "enable_authenticator_manager" is set to true. If you rely on this behavior, set it to false.');
116+
}
117+
114118
$loader->load('security_authenticator.xml');
115119

116120
// The authenticator system no longer has anonymous tokens. This makes sure AccessListener

src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/SecurityExtensionTest.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -505,6 +505,21 @@ public function provideEntryPointRequiredData()
505505
];
506506
}
507507

508+
public function testAlwaysAuthenticateBeforeGrantingCannotBeTrueWithAuthenticationManager()
509+
{
510+
$this->expectException(InvalidConfigurationException::class);
511+
$this->expectExceptionMessage('The security option "always_authenticate_before_granting" cannot be used when "enable_authenticator_manager" is set to true. If you rely on this behavior, set it to false.');
512+
513+
$container = $this->getRawContainer();
514+
$container->loadFromExtension('security', [
515+
'enable_authenticator_manager' => true,
516+
'always_authenticate_before_granting' => true,
517+
'firewalls' => ['main' => []],
518+
]);
519+
520+
$container->compile();
521+
}
522+
508523
protected function getRawContainer()
509524
{
510525
$container = new ContainerBuilder();

src/Symfony/Component/Security/Http/Authentication/NoopAuthenticationManager.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,5 +29,6 @@ class NoopAuthenticationManager implements AuthenticationManagerInterface
2929
{
3030
public function authenticate(TokenInterface $token)
3131
{
32+
return $token;
3233
}
3334
}

0 commit comments

Comments
 (0)
0