Wie können wir unseren Code ausführen, nachdem sich der Benutzer (erfolgreich) mit http_basic_ldap
angemeldet hat?symfony 3.3 http_basic_ldap Ereignis für (erfolgreiche) Anmeldung?
http://symfony.com/doc/3.3/security/ldap.html#configuration-example-for-http-basic
(dickes Lob an Devs für die Herstellung von ldap Login so einfach!)
https://symfony.com/doc/3.3/components/security/authentication.html#authentication-events
Ich habe versucht, mit AuthenticationEvents::AUTHENTICATION_SUCCESS
und SecurityEvents::INTERACTIVE_LOGIN
aber entweder mein Code ist falsch, oder solche Ereignisse nicht für http_basic_ldap
gebrannt.
mein 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. Mein Ziel ist es, die Benutzerrollen aus der Symfony Datenbank/Entity zu laden (aber immer über ldap einloggen).