How to fix Symfony 5 Exception: Because you have multiple guard authenticators, you need to set the "guard.entry_point" key to one of your authenticators

How to fix Symfony 5 Exception: Because you have multiple guard authenticators, you need to set the "guard.entry_point" key to one of your authenticators

If you find this exception in your project, chances are that you are using more than 1 authenticator in your project. This happens when you want to offer your users different authentication mechanisms in your application, like the possibility to log in to your application with Facebook, Github, or Twitter.

Normally, with this logic, you will always have a single entry point, which will be your default authenticator. For example, if the application allows users to register in your application using their own email and to login as well with a social network (Github and Facebook), the entry point will be the default LoginFormAuthenticator of Symfony. To prevent this exception from appearing, you simply need to specify which authenticator class will be the entry point defining the security.firewalls.<your-firewall>.guard.entry_point key:

# project/config/packages/security.yaml
security:
    firewalls:
        main:
            anonymous: true
            guard:
                # Set as entry point the default authenticator of the application (LoginFormAuthenticator) to fix the issue
                entry_point: App\Security\LoginFormAuthenticator
                # In this example, we have 3 authenticators, one of our sf application
                # and 2 social authenticators, therefore we use LoginFormAuthenticator as the entry point
                authenticators:
                    - App\Security\LoginFormAuthenticator
                    - App\Security\GithubAuthenticator
                    - App\Security\FacebookAuthenticator

Happy coding ❤️!

This could interest you

Become a more social person