Generally all login stuff in symfony is executed by a listener to the kernel.request
event, mostly within the Firewall
listener of the Symfony security component. I did not use the HWIOAuthBundle bundle yet, but it seems it also just uses the Symfony Security component.
If you just want to execute certain actions before the login/authentication happens, you only need to register an event listener to the kernel.request
with a higher priority than the Firewall
listener.
You can do that as described in the Symfony docs (Events and Event Listeners). First create your Event listener class in src/AppBundle/EventListener/YourListener.php
:
namespace AppBundle\EventListener;
use Symfony\Component\HttpKernel\Event\GetResponseEvent;
class YourListener
{
public function onKernelRequest(GetResponseEvent $event)
{
// do stuff
}
}
Then register your service in your app/config/services.yml
file:
services:
AppBundle\EventListener\YourListener:
tags:
- { name: kernel.event_listener, event: kernel.request, priority: 9 }
According to this page the Firewall has a priority of 8. So the priority of your event listener should be higher than that to be executed before the login happens (I used 9 in the example above).