本文介绍了如何将sha1()密码转换为FOSUserBundle?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我拥有使用 sha1()
功能加密密码的遗留应用程序,没有盐。
现在网站正在转换成Symfony2和FOSUserBundle,如何将它们转移到新的数据库?
解决方案
我有同样的问题p>
只需覆盖编码器,如@iamdto解释
#app / config /security.yml
security:
编码器:
FOS\UserBundle\Model\UserInterface:
id:your.custom.encoder
你的课程应该是
Symfony\Component\Security\Core\Encoder\PasswordEncoderInterface;
class CustomEncoder实现PasswordEncoderInterface
{
public function encodePassword($ raw,$ salt){
//不要在这里使用盐
return sha1($ raw);
}
public function isPasswordValid($ encoded,$ raw,$ salt){
return $ encoded === $ this-> encodePassword($ raw,$ salt) ;
}
}
您应该添加列版本以获取遗产用户并在下次登录时更新他们的信息
I have legacy application that keeps passwords encrypted with sha1()
function, no salt.
Now that site is being converted into Symfony2 and FOSUserBundle, how can I transfer them to new database?
解决方案
i had the same problem
just override the encoder like explained by @iamdto
# app/config/security.yml
security:
encoders:
FOS\UserBundle\Model\UserInterface:
id: your.custom.encoder
Your class should be
use Symfony\Component\Security\Core\Encoder\PasswordEncoderInterface;
class CustomEncoder implements PasswordEncoderInterface
{
public function encodePassword( $raw, $salt ) {
//do not use salt here
return sha1($raw);
}
public function isPasswordValid( $encoded, $raw, $salt ) {
return $encoded === $this->encodePassword( $raw, $salt );
}
}
You should add a column "version" to get legacy users and update their infos on next login
这篇关于如何将sha1()密码转换为FOSUserBundle?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!