Skip to content

Commit

Permalink
[Security\Core] Fix NoopAuthenticationManager::authenticate() return …
Browse files Browse the repository at this point in the history
…value
  • Loading branch information
chalasr authored and nicolas-grekas committed May 16, 2020
1 parent 960aefd commit 12224cd
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
4 changes: 4 additions & 0 deletions DependencyInjection/SecurityExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,10 @@ public function load(array $configs, ContainerBuilder $container)
$loader->load('security_rememberme.xml');

if ($this->authenticatorManagerEnabled = $config['enable_authenticator_manager']) {
if ($config['always_authenticate_before_granting']) {
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.');
}

$loader->load('security_authenticator.xml');

// The authenticator system no longer has anonymous tokens. This makes sure AccessListener
Expand Down
15 changes: 15 additions & 0 deletions Tests/DependencyInjection/SecurityExtensionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -505,6 +505,21 @@ public function provideEntryPointRequiredData()
];
}

public function testAlwaysAuthenticateBeforeGrantingCannotBeTrueWithAuthenticationManager()
{
$this->expectException(InvalidConfigurationException::class);
$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.');

$container = $this->getRawContainer();
$container->loadFromExtension('security', [
'enable_authenticator_manager' => true,
'always_authenticate_before_granting' => true,
'firewalls' => ['main' => []],
]);

$container->compile();
}

protected function getRawContainer()
{
$container = new ContainerBuilder();
Expand Down

0 comments on commit 12224cd

Please sign in to comment.