how do we run our code after user (successfully) logs in with http_basic_ldap?
http://symfony.com/doc/3.3/security/ldap.html#configuration-example-for-http-basic
(kudos to devs for making ldap login that easy!)
https://symfony.com/doc/3.3/components/security/authentication.html#authentication-events
i tried with AuthenticationEvents::AUTHENTICATION_SUCCESS and SecurityEvents::INTERACTIVE_LOGIN but either my code is wrong, or those events are not fired for http_basic_ldap.
my test src/AppBundle/EventSubscriber/LoginSubscriber.php:
namespace AppBundle\EventSubscriber;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\Security\Core\AuthenticationEvents;
use Symfony\Component\Security\Http\SecurityEvents;
class LoginSubscriber implements EventSubscriberInterface
{
public function onUserLogin ($dunno)
{
file_put_contents("/tmp/dunno.log", "yay, got called!\n", FILE_APPEND);
}
public static function getSubscribedEvents()
{
return [
AuthenticationEvents::AUTHENTICATION_SUCCESS => 'onUserLogin',
SecurityEvents::INTERACTIVE_LOGIN => 'onUserLogin',
];
}
}
ps. my goal is to load the users roles from symfony database/entity (but always login through ldap).