【问题标题】:Using cakephp's Auth component with salted password hashes使用 cakephp 的 Auth 组件和加盐密码哈希
【发布时间】:2010-06-17 22:57:49
【问题描述】:

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

【问题讨论】:

  • 如果有人发现这个并想用 CakePHP 2.x 做同样的事情,请参阅this question

标签: php security cakephp


【解决方案1】:

您可以从这里开始 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;
    }
}

【讨论】:

    【解决方案2】:

    Auth 组件中没有这样的功能。看看Random String generator CakePHP component

    【讨论】:

      【解决方案3】:

      here 所述,研究覆盖 Auth 组件使用的哈希函数。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2011-12-06
        • 2010-11-30
        • 1970-01-01
        • 1970-01-01
        • 2019-09-12
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多