If I remember correctly, the trick is to set the token directly into the security.context
service. Since you are using a username/password pair, you could instantiate a UsernamePasswordToken
class and set it in the security context.
$securityContext = $this->get('security.context');
$token = new UsernamePasswordToken($username, $password, $providerKey, $roles);
$securityContext->setToken($token);
For the $user
, $password
and $roles
parameters, it's obvious. For the $providerKey
, I must admit I don't know what to put in this one exactly. So, maybe getting the token from an AuthenticationProvider
could be easier, or if maybe you already have access to a TokenInterface
object.
The main point of my anwser is to set the token directly into the SecurityContext
object via the method setToken
. But I'm not sure exactly how to retrieve or create the token :)
Hope this help.
Regards,
Matt