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

Skip to content

[Security] Cannot have a custom authenticator which implements EventSubscriberInterface #59071

Closed
@misaert

Description

@misaert

Symfony version(s) affected

7.2.0

Description

Hi,

When I try to update from Symfony 7.1 to 7.2. I have an error on cache clear:

$ bin/console cache:clear

In RegisterListenersPass.php line 129:
                                                                                                                                             
  Service "debug.App\Security\MyCustomAuthenticator" must implement interface "Symfony\Component\EventDispatcher\EventSubscriberInterface".  

It seems to be related to:

When I add this code on vendor/symfony/security-bundle/DependencyInjection/SecurityExtension.php line 646:

        if ($container->hasDefinition('debug.security.firewall')) {
            foreach ($authenticationProviders as $authenticatorId) {
                if ($authenticatorId === MyCustomAuthenticator::class) {
                    continue;
                }

                $container->register('debug.'.$authenticatorId, TraceableAuthenticator::class)
                    ->setDecoratedService($authenticatorId)
                    ->setArguments([new Reference('debug.'.$authenticatorId.'.inner')])
                ;
            }
        }

It works.

Is it an issue? Why I can't implement EventSubscriberInterface anymore?

Thanks,

Mickaël

How to reproduce

I created a repository: https://github.com/misaert/test-custom-authenticator/commits/main/.

The last commit is with Symfony 7.2. Before this, we can launch bin/console cache:clear but with this commit, we have this error:

$ bin/console cache:clear

In RegisterListenersPass.php line 129:
                                                                                                                                             
  Service "debug.App\Security\MyCustomAuthenticator" must implement interface "Symfony\Component\EventDispatcher\EventSubscriberInterface".  
                                                                                                                                             

Possible Solution

No response

Additional Context

No response

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