Skip to content

Commit 12224cd

Browse files
chalasrnicolas-grekas
authored andcommitted
[Security\Core] Fix NoopAuthenticationManager::authenticate() return value
1 parent 960aefd commit 12224cd

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

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

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();

0 commit comments

Comments
 (0)