【问题标题】:Cakephp 2.0 Auth AND Basic AuthenticationCakephp 2.0 身份验证和基本身份验证
【发布时间】:2011-11-22 21:50:47
【问题描述】:

我正在将 CakePHP 1.3 应用升级到 2.0.3。

以前,我可以使用 Auth 组件来登录用户,并使用 Security 组件来模拟 Basic 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')
        )
    );

它仍然想使用我的用户模型和数据库。我错过了什么吗?

【问题讨论】:

    标签: .htaccess cakephp authentication


    【解决方案1】:

    查看 BaseAuthenticateBasicAuthenticate 类会表明 Cake 不再支持以这种方式定义用户和密码。

    您可能必须扩展 BasicAuthenticate 类并覆盖它的 getUser() 方法。

    也许其他人可以对此有所了解?

    【讨论】:

    • 是的,这是一个考虑因素。我可能最终会这样做。
    猜你喜欢
    • 2012-01-16
    • 1970-01-01
    • 2011-01-28
    • 1970-01-01
    • 2013-10-06
    • 2021-02-10
    • 2013-11-10
    • 2021-06-20
    • 1970-01-01
    相关资源
    最近更新 更多