Skip to content

[Security\Core] Fix NoopAuthenticationManager::authenticate() return value #36805

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 16, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,6 @@ class NoopAuthenticationManager implements AuthenticationManagerInterface
{
public function authenticate(TokenInterface $token)
{
return $token;
}
}