微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

如何替换cakephp密码哈希算法?

我有一个现有的数据库,我正试图把蛋糕应用程序放在上面.旧的应用程序在Perl中使用crypt()来散列密码.我需要在 PHP应用程序中执行相同的操作.

在标准的cakePHP应用程序中进行更改的正确位置在哪里?这样的改变会是什么样的?

我搞定了……

这是我的AppController:

class AppController extends Controller {
    var $components = array('Auth');

    function beforeFilter() {
        // this is part of cake that serves up static pages,it should be authorized by default
        $this->Auth->allow('display');
        // tell cake to look on the user model itself for the password hashing function
        $this->Auth->authenticate = ClassRegistry::init('User');
        // tell cake where our credentials are on the User entity
        $this->Auth->fields = array(
           'username' => 'user','password' => 'pass',);
        // this is where we want to go after a login... we'll want to make this dynamic at some point
        $this->Auth->loginRedirect = array('controller'=>'users','action'=>'index');
    }
}

然后这是用户

<?PHP
class User extends AppModel {
    var $name = 'User';

    // this is used by the auth component to turn the password into its hash before comparing with the DB
    function hashPasswords($data) {
         $data['User']['pass'] = crypt($data['User']['pass'],substr($data['User']['user'],2));
         return $data;
    }
}
?>

我认为其他一切都很正常.

这是一个很好的资源:http://teknoid.wordpress.com/2008/10/08/demystifying-auth-features-in-cakephp-12/

原文地址:https://www.jb51.cc/php/130625.html

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐