I finaly found a solution, but not sure it's the best way to do the stuff.
I added a listener when the login failed and check if it's a user from WordPress.
Now I'm looking for a solution to handle the "remember me" checkbox because the user is a authenticate programmatically. Here is the code :
public function onAuthenticationFailure(Request $request, AuthenticationException $exception)
{
$username = $request->request->get('_username');
$password = $request->request->get('_password');
$user = $this->doctrine->getRepository('AppBundle:User')->findOneByUsername($username);
if ($user instanceof User && $user->getFromWordpress() == true) {
//The class use by WordPress to check / encode passwords
$hasher = new PasswordHash(8, TRUE);
//User provide the right password
if ($hasher->CheckPassword($password, $user->getWordpressPassword())){
//Programmatically authenticate the user
$token = new UsernamePasswordToken($user, $user->getPassword(), "main", $user->getRoles());
$this->tokenStorage->setToken($token);
$event = new InteractiveLoginEvent($request, $token);
$this->eventDispacher->dispatch("security.interactive_login", $event);
//Set the password with the Symfony2 encoder
$encoder = $this->encoderFactory->getEncoder($user);
$password = $encoder->encodePassword($password, $user->getSalt());
$user->setPassword($password);
$user->setFromWordpress(false);
$this->doctrine->getManager()->persist($user);
$this->doctrine->getManager()->flush();
//Finnaly send login ok response
return $this->onAuthenticationSuccess($request, $token);
}
}
//Login failed code ...
//.....
}