简体   繁体   English

使用cakephp的Auth组件和salted密码哈希

[英]Using cakephp's Auth component with salted password hashes

如何让cakephp的Auth组件创建,使用和存储随机盐密码?

You can start here http://book.cakephp.org/view/566/Change-Hash-Function , and set the $authenticate variable to your user model: 您可以从http://book.cakephp.org/view/566/Change-Hash-Function开始,并将$authenticate变量设置为您的用户模型:

class User extends AppModel {
    function hashPasswords($data) {
        if (isset($data['User']['password'])) {
            //Get the user to get the salt
            $user = $this->findByUsername($data['User']['username']);
            //Let's say you have a "salt" field in your db 
            $data['User']['password'] = md5($data['User']['password'].$user['User']['salt']);
            return $data;
        }
        return $data;
    }
}

There is no such functionality in Auth component. Auth组件中没有此类功能。 Take a look at Random String generator CakePHP component . 看看Random String generator CakePHP组件

考虑覆盖所描述使用的验证组件的哈希函数在这里

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM