Description
Symfony version(s) affected: 5.3.0
Description
A application that do not depends on symfony/console
fails with the error You have requested a non-existent service "security.command.debug_firewall"
. This only happens with the new Authenticator-based Security.
How to reproduce
Create an application that do not depends on symfony/console
. If you use a new authentication security with a custom authenticator, you should get this error.
Possible Solution
In the security-bundle
, in SecurityExtension.php
, the command is loaded conditionnaly:
if (class_exists(Application::class)) {
$loader->load('debug_console.php');
$debugCommand = $container->getDefinition('security.command.debug_firewall');
$debugCommand->replaceArgument(4, $this->authenticatorManagerEnabled);
}
However, in the function createFirewall
, this condition is not present:
// Add authenticators to the debug:firewall command
$debugCommand = $container->getDefinition('security.command.debug_firewall');
$debugCommand->replaceArgument(3, array_merge($debugCommand->getArgument(3), [$id => $authenticators]));
This leads to the error Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException: You have requested a non-existent service "security.command.debug_firewall".
Additional context
A workaround is to add the dependency to symfony/console
.