I am having authentication issues, but this only happens in special circumstances. Authentication is done through a third-party API, so I wrote my own class of service provider, and inside this class there is code that synchronizes data between the API and Symfony, as part of the synchronization process that determines which roles a user should have. After that, he establishes the relationship between the roles and the user through the ManyToMany relationship.
The getRoles () method in my User object gets role objects from the database and turns them into an array of strings, role names come from my database, and it all starts with ROLE _.
If I log into the system with an account that should not have additional roles, it works fine, but if I log in to the account, which should have roles, I will simply send it back to the login screen without an error message.
I checked the log and saw these entries:
security.INFO: User " test105@example.com " has been authenticated successfully [] [] event.DEBUG: Notified event "security.interactive_login" to listener "Pogo\MyBundle\Listener\LoginListener::onSecurityInteractivelogin". [] [] event.DEBUG: Listener "Symfony\Component\Security\Http\Firewall::onKernelRequest" stopped propagation of the event "kernel.request". [] [] event.DEBUG: Listener "Symfony\Bundle\FrameworkBundle\EventListener\RouterListener" was not called for event "kernel.request". [] [] event.DEBUG: Listener "Symfony\Bundle\AsseticBundle\EventListener\RequestListener" was not called for event "kernel.request". [] [] event.DEBUG: Notified event "kernel.response" to listener "Symfony\Component\Security\Http\Firewall\ContextListener::onKernelResponse". [] [] security.DEBUG: Write SecurityContext in the session [] [] event.DEBUG: Notified event "kernel.response" to listener "Symfony\Component\HttpKernel\EventListener\ResponseListener::onKernelResponse". [] [] event.DEBUG: Notified event "kernel.response" to listener "Symfony\Bundle\SecurityBundle\EventListener\ResponseListener::onKernelResponse". [] [] event.DEBUG: Notified event "kernel.response" to listener "Symfony\Bridge\Monolog\Handler\FirePHPHandler::onKernelResponse". [] [] event.DEBUG: Notified event "kernel.response" to listener "Sensio\Bundle\FrameworkExtraBundle\EventListener\CacheListener::onKernelResponse". [] [] event.DEBUG: Notified event "kernel.response" to listener "Symfony\Component\HttpKernel\EventListener\ProfilerListener::onKernelResponse". [] [] event.DEBUG: Notified event "kernel.response" to listener "Symfony\Bundle\WebProfilerBundle\EventListener\WebDebugToolbarListener::onKernelResponse". [] [] event.DEBUG: Notified event "kernel.request" to listener "Symfony\Bundle\FrameworkBundle\EventListener\RouterListener::onEarlyKernelRequest". [] [] event.DEBUG: Notified event "kernel.request" to listener "Symfony\Bundle\FrameworkBundle\EventListener\SessionListener::onKernelRequest". [] [] event.DEBUG: Notified event "kernel.request" to listener "Symfony\Component\Security\Http\Firewall::onKernelRequest". [] [] security.INFO: Populated SecurityContext with an anonymous Token [] [] event.DEBUG: Notified event "kernel.exception" to listener "Symfony\Component\Security\Http\Firewall\ExceptionListener::onKernelException". [] [] security.DEBUG: Access denied (user is not fully authenticated); redirecting to authentication entry point [] [] security.DEBUG: Calling Authentication entry point [] []
I donβt understand how it can be authenticated from above, and then when it checks the firewall, it detects an anonymous token, so it probably sends me back to the login screen.
Settings for my / access _control firewall:
firewalls: public: pattern: /.* anonymous: true tessitura_login: login_path: /account/login check_path: /secure/login_check logout: path: /secure/logout target: / access_control: - { path: ^/secure/.*, role: ROLE_USER } - { path: ^/admin.*, role: ROLE_ADMIN } - { path: ^/account/login/?, role: IS_AUTHENTICATED_ANONYMOUSLY } - { path: /.*, role: IS_AUTHENTICATED_ANONYMOUSLY }
Any help with this would be appreciated commendably, I spent several hours on it now and completely lost consciousness.