所以我想創建一個新的Silex應用程序並使用包含的安全捆綁包。爲了簡單起見,我打算使用基本的密碼編碼。如何在Silex中將密碼編碼器附加到用戶界面?
根據Silex文檔我創建了一個自定義用戶提供程序。但是,此用戶界面似乎並未使用默認的密碼編碼。
我能順利拿到密碼進行的
$password = $app['security.encoder.digest']->encodePassword('foo');
然而,當我使用的例子
// 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());
我得到的
的RuntimeException:無編碼器已經配置了帳戶
在Symfony2中,我會使用類似如下的
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
但這似乎並不在這裏是如此。我似乎無法找到任何類型的setEncoder方法,所以我有點難住。
這很有道理。我認爲這是沿着這些線路的某個地方,但是說明所有內容都使用默認設置的文檔。非常感謝你! – fafnirbcrow