Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Service "security.command.debug_firewall" not found error #41769

Closed
@psdesse

Description

@psdesse

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions