Cakephp 2.0 身份验证和基本身份验证
我正在将 CakePHP 1.3 应用程序升级到 2.0.3。
以前,我能够使用 Auth 组件来登录用户,并使用 Security 组件来模拟基本 HTTP 身份验证。 (就好像我设置了一个 .htaccess 文件来密码保护页面)
我曾经这样做:
$this->Security->loginOptions = array('type'=>'basic','realm'=>'training');
$this->Security->loginUsers = array("student"=>"student2010");
$this->Security->requireLogin();
现在看来,即使我使用:
public $components = array(
'Auth' => array(
'authenticate' => array('Basic')
)
);
它仍然想使用我的用户模型和数据库。我错过了什么吗?
I'm upgrading a CakePHP 1.3 app to 2.0.3.
Previously, I was able to use the Auth component to log users in, and use the Security component to emulate Basic HTTP authentication. (as if I had setup an .htaccess file to password protect a page)
I used to do this:
$this->Security->loginOptions = array('type'=>'basic','realm'=>'training');
$this->Security->loginUsers = array("student"=>"student2010");
$this->Security->requireLogin();
Now it appears that even if I use:
public $components = array(
'Auth' => array(
'authenticate' => array('Basic')
)
);
It still wants to use my User model and database. Am I missing something?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
查看 BaseAuthenticate 和 BasicAuthenticate 类会发现 Cake 不再支持以这种方式定义用户和密码。
您可能必须扩展 BasicAuthenticate 类并覆盖它的 getUser() 方法。
也许其他人可以阐明这一点?
Looking at the BaseAuthenticate and BasicAuthenticate classes would suggest that Cake no longer supports defining users and passwords that way.
You would probably have to extend the BasicAuthenticate class and override it's getUser() method.
Perhaps someone else could shed some light on this?