我正在更新我的PS 1.6到1.7。我知道PS1.6使用这种加密方法md5(_COOKIE_KEY_.$passwd),但我们之前将其转换为md5($passwd)是为了与我们之前的shop not-prestashop兼容。
现在我们希望更新到1.7,并且我们看到加密方法已经更改为hash()。我们已经实现了登录之前的用户更改此功能:getByEmail(),但现在我们希望注册工作正常(将密码保存为md5($plaintextpassword))。我们知道新的加密方法更安全,不建议使用md5($plaintextpassword),但现在我们无法改变这一点。
我们在Classes/Customer.php中更改了以下所有行:
$this->passwd = $crypto->hash($password);至:
$this->passwd = md5($password);但是,当我们注册一个新用户时,由于所有这些更改,它被保存为$2y$10$VPm9ygay2ldd0Vu0J4ttQuOdD/mIytURV/nXCXKs4GcB4AkIWtaQm ()方法,格式为hash(),而不是这样: bcef5cffa6f4bb0abb94cf6fa7a7cb2f。我找不到我必须在哪里更改才能保存为所需的格式?
发布于 2019-10-22 02:36:35
您必须覆盖PrestaShop并添加新的附加密码检查器:
if(!loginWithOriginalMethod($password)) {
loginWithAdditionalMethod($password);
}通过这种方式,您的新老客户都可以登录到您的商店
发布于 2020-12-06 01:32:36
如果您可以直接在DB中导入之前的1.6哈希值,并保留相同的cookie密钥,则该函数是向后兼容的。
但是,如果像我一样,在使用csv功能导入时,1.6散列已经使用新的cookie密钥进行了重新散列,则需要更新src/Core/Crypto/Hashing.php,将最后一个函数替换为:
确保将替换为来自Prestashop 1.6的cookie密钥
private function initHashMethods()
{
$this->hashMethods = array(
'bcrypt' => array(
'option' => array(),
'hash' => function ($passwd, $staticSalt, $option) {
return password_hash($passwd, PASSWORD_BCRYPT);
},
'verify' => function ($passwd, $hash, $staticSalt) {
/*
* Prevent enumeration because nothing happens
* when there is no, or an invalid hash.
* Also, change the password to be sure it's not maching
* the new hash.
* The new hash is equal to 'test' in BCRYPT context.
*/
if (empty($hash)) {
$hash = '$2y$10$azRqq.pN0OlWjeVfVMZXOOwqYAx1hMfme6ZnDV.27grGOEZvG.uAO';
$passwd = 'wrongPassword';
}
return password_verify($passwd, $hash);
},
),
'md5' => array(
'option' => array(),
'hash' => function ($passwd, $staticSalt, $option) {
return md5($staticSalt . $passwd);
},
'verify' => function ($passwd, $hash, $staticSalt) {
return md5($staticSalt . $passwd) === $hash;
},
),
'bcryptmd5' => array(
'option' => array(),
'hash' => function ($passwd, $staticSalt, $option) {
return password_hash(md5('<your 1.6 cookie key>' . $passwd), PASSWORD_BCRYPT);
},
'verify' => function ($passwd, $hash, $staticSalt) {
/*
* Prevent enumeration because nothing happens
* when there is no, or an invalid hash.
* Also, change the password to be sure it's not maching
* the new hash.
* The new hash is equal to 'test' in BCRYPT context.
*/
if (empty($hash)) {
$hash = '$2y$10$azRqq.pN0OlWjeVfVMZXOOwqYAx1hMfme6ZnDV.27grGOEZvG.uAO';
$passwd = 'wrongPassword';
}
return password_verify(md5('<your 1.6 cookie key>' . $passwd), $hash);
},
),
);
}https://stackoverflow.com/questions/58488649
复制相似问题