Using cakephp Auth with salted password hashes

How can I make the Auth cakephp component create, use and store a random salt with a password?

+3
source share
3 answers

You can start here http://book.cakephp.org/view/566/Change-Hash-Function and set the variable $authenticateto your user model:

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 say you have a "salt" field in your db 
            $data['User']['password'] = md5($data['User']['password'].$user['User']['salt']);
            return $data;
        }
        return $data;
    }
}
+4
source

There is no such function in the Auth component. Take a look at CakePHP Random Line Generator .

0
source

-, Auth, .

0

Source: https://habr.com/ru/post/1750596/


All Articles