So I am trying to create a new Silex application and use the Security bundle included. For simplicities sake I was going to go with the basic password encoding.
Per the Silex documentation http://silex.sensiolabs.org/doc/providers/security.html I have created a custom User Provider. However this user interface does not seem to use the default password encoding.
I can successfully get a password out of
$password = $app['security.encoder.digest']->encodePassword('foo');
However when I use the example
// find the encoder for a UserInterface instance
$encoder = $app['security.encoder_factory']->getEncoder($user);
// compute the encoded password for foo
$password = $encoder->encodePassword('foo', $user->getSalt());
I get the
RuntimeException: No encoder has been configured for account
In symfony2, I would use something like the following
encoders:
somename:
class: Acme\DemoBundle\Entity\User
Acme\DemoBundle\Entity\User: sha512
Acme\DemoBundle\Entity\User: plaintext
Acme\DemoBundle\Entity\User:
algorithm: sha512
encode_as_base64: true
iterations: 5000
Acme\DemoBundle\Entity\User:
id: my.custom.encoder.service.id
But that doesnt seem to be the case here. I can’t seem to find any type of setEncoder method so I am a bit stumped.
You need to reconstruct the
EncoderFactoryto add your custom implementation:(oh and please, don’t use a Base64Encoder() for password ;))