3

今天我们已将 PHP 从5.5.7更新到5.6.13,函数中的所有密码哈希password_hash()都停止工作。

是否有任何信息说明为什么会发生这种情况?我们做错了什么?

当我使用密码重置功能创建密码的新哈希时,它再次正常工作。

密码存储在 MySQL 数据库中,使用varchar(255). 使用的类是Passwords.php

身份验证如下所示:

// Try to find the user from database
$user = $this->getUser($email);

// If the provided password is invalid
if (!isset($user) || !$user->isPasswordValid($password)) {
    throw new AuthenticationException('portal.user.signInFailed');
}

isPasswordValid 方法如下所示:

/**
 * Validate given User password.
 * @param  string  $value  Password to validate
 * @return bool
 */
public function isPasswordValid($value)
{
    return Passwords::verify($value, $this->password);
}

这就是我的散列函数的样子:

/**
 * Set and hash new password value.
 * @param  string  $value  New password
 * @return static
 */
public function setPassword($value)
{
    $this->password = Passwords::hash($value);
    return $this;
}

这是更新前(不工作)和密码重置后(工作)的哈希值

$2y$10$wMM1rXjwOIJb8Ga0L0mINevOvZxY4C2ebucBDNZ1P1dkp.J22KGzm
$2y$10$cr6HeWoS2MDxK1tbJvaEjefMiex1RgeG/JrHTrVznN2DeBPVJnVC.

我宁愿不给你密码本身:)

4

0 回答 0