将我的 java 个应用程序与 table 个 fosuserbundle 用户同步
Synchronise my java apps with table user of fosuserbundle
我正在尝试创建一个桌面应用程序 (java),它指向我网站的同一个数据库(使用 symfony 2 创建),但我遇到无法插入列的问题 "password" 和 "salt" 使用由 fosuserBundle 生成的相同加密类型 sha512
,我不知道 fosuserBundle 如何生成 "salt" 值。
我的编码器当前设置为:
security:
encoders:
FOS\UserBundle\Model\UserInterface: sha512
检查FOS\UserBundle\Model\User
__construct
方法:
public function __construct()
{
$this->salt = base_convert(sha1(uniqid(mt_rand(), true)), 16, 36);
$this->enabled = false;
$this->locked = false;
$this->expired = false;
$this->roles = array();
$this->credentialsExpired = false;
}
最后我找到了使 table 中的字段 "salt" 可以忽略不计的解决方案 fos_user 就是让这个方法只是 return 密码
namespace Symfony\Component\Security\Core\Encoder;
protected function mergePasswordAndSalt($password, $salt)
{
if (empty($salt)) {
return $password;
}
if (false !== strrpos($salt, '{') || false !== strrpos($salt, '}')) {
throw new \InvalidArgumentException('Cannot use { or } in salt.');
}
return $password;
}
我正在尝试创建一个桌面应用程序 (java),它指向我网站的同一个数据库(使用 symfony 2 创建),但我遇到无法插入列的问题 "password" 和 "salt" 使用由 fosuserBundle 生成的相同加密类型 sha512
,我不知道 fosuserBundle 如何生成 "salt" 值。
我的编码器当前设置为:
security:
encoders:
FOS\UserBundle\Model\UserInterface: sha512
检查FOS\UserBundle\Model\User
__construct
方法:
public function __construct()
{
$this->salt = base_convert(sha1(uniqid(mt_rand(), true)), 16, 36);
$this->enabled = false;
$this->locked = false;
$this->expired = false;
$this->roles = array();
$this->credentialsExpired = false;
}
最后我找到了使 table 中的字段 "salt" 可以忽略不计的解决方案 fos_user 就是让这个方法只是 return 密码
namespace Symfony\Component\Security\Core\Encoder;
protected function mergePasswordAndSalt($password, $salt)
{
if (empty($salt)) {
return $password;
}
if (false !== strrpos($salt, '{') || false !== strrpos($salt, '}')) {
throw new \InvalidArgumentException('Cannot use { or } in salt.');
}
return $password;
}