Bonjour à tous !

Etant depuis pas mal de temps sur la création d'un système d'authentification couplant un Ldap et une base de données, je me heurte à un problème majeur.

J'ai suivi le tuto disponible sur le site de Symfony (http://symfony.com/doc/current/cookb..._provider.html), et me suis très largement inspiré du FOSFacebookBundle.

Cependant, mon listener ne semblait pas fonctionner. En effet, il était appellé (echo témoin), mais les erreurs du UsernamePasswordFormAuthenticationListener de Symfony étaient déclenchés.

J'ai donc voulu changé de méthode en implémentant la classe AbstractAuthenticationListener en lieu et place du AbstractListener.

Et c'est le drame, si je la défini en tant que classe abstraite, j'ai une fatal erreur car ma variable providerId est nulle.

Je voulais donc surcharger le constructeur en y injectant mes propres paramètres. Mais impossible de trouver les mots clés de Symfony correspondant !

Voici ma classe :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
 
<?php
namespace Sikwan\SikwanSecurityBundle\Security\Firewall;
 
use Sikwan\SikwanSecurityBundle\Security\Authentication\Token\SikwanUserToken;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\Event\GetResponseEvent;
use Symfony\Component\Security\Http\Firewall\AbstractAuthenticationListener;
use Symfony\Component\Security\Core\Exception\AuthenticationException;
use Symfony\Component\Security\Core\SecurityContextInterface;
use Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface;
use Symfony\Component\Security\Core\Authentication\Token\UsernamePasswordToken;
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
 
 
class SikwanListener extends AbstractAuthenticationListener
{
	protected $csrfProvider;
 
	/**
     * {@inheritdoc}
     */
    public function __construct(SecurityContextInterface $securityContext, AuthenticationManagerInterface $authenticationManager, SessionAuthenticationStrategyInterface $sessionStrategy, HttpUtils $httpUtils, $providerKey, array $options = array(), AuthenticationSuccessHandlerInterface $successHandler = null, AuthenticationFailureHandlerInterface $failureHandler = null, LoggerInterface $logger = null, EventDispatcherInterface $dispatcher = null, CsrfProviderInterface $csrfProvider = null)
    {
 
        parent::__construct($securityContext, $authenticationManager, $sessionStrategy, $httpUtils, $providerKey, array_merge(array(
            'username_parameter' => '_username',
            'password_parameter' => '_password',
            'csrf_parameter'     => '_csrf_token',
            'intention'          => 'authenticate',
            'post_only'          => true,
        ), $options), $successHandler, $failureHandler, $logger, $dispatcher);
 
        $this->csrfProvider = $csrfProvider;
    }
 
	protected function attemptAuthentication(Request $request)
    {
    	if ($this->options['post_only'] && 'post' !== strtolower($request->getMethod())) {
            if (null !== $this->logger) {
                $this->logger->debug(sprintf('Authentication method not supported: %s.', $request->getMethod()));
            }
 
            return null;
        }
 
        if (null !== $this->csrfProvider) {
            $csrfToken = $request->get($this->options['csrf_parameter'], null, true);
 
            if (false === $this->csrfProvider->isCsrfTokenValid($this->options['intention'], $csrfToken)) {
                throw new InvalidCsrfTokenException('Invalid CSRF token.');
            }
        }
		$username = trim($request->get($this->options['username_parameter'], null, true));
        $password = $request->get($this->options['password_parameter'], null, true);
 
        $request->getSession()->set(SecurityContextInterface::LAST_USERNAME, $username);
 
        return $this->authenticationManager->authenticate(new UsernamePasswordToken($username, $password, $this->providerKey));
	}
}
(Ma fonction attemptAuthentication est celle de base je ne l'ai pas encore modifiée vu que l'erreur est en amont).

Et voici ce que j'envoie à mon Container :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
 
    sikwan.security.authentication.listener:
        class: Sikwan\SikwanSecurityBundle\Security\Firewall\SikwanListener
        parent: security.authentication.listener.abstract
        arguments: [@security.context, @security.authentication.manager]
J'ai donc les deux premiers paramètres de renseignés, mais je ne sais pas comment faire pour les autres.

Quelqu'un a rencontré ce problème ?