【发布时间】:2013-10-24 13:58:05
【问题描述】:
我在 CakePHP 中扩展了 BaseAuthorise 并创建了一个名为 LdapAuthenticate 的新类,它位于我的 /app/Controller/Component/Auth/LdapAuthenticate 中,目前看起来像这样
<?php
App::uses('BaseAuthorize', 'Controller/Component/Auth');
class LdapAuthenticate extends BaseAuthorize {
public function authenticate(CakeRequest $request, CakeResponse $response) {
// Do things for ldap here.
echo "Running...";
}
}
在我的 AppControl 中
public $components = array(
'Session',
'Auth' => array(
'loginRedirect' => array('controller' => 'posts', 'action' => 'index'),
'logoutRedirect' => array('controller' => 'pages', 'action' => 'display', 'home'),
'authenticate' => array('Ldap')
)
);
然后在我的登录方法中,我有
public function login() {
if ($this->request->is('post')) {
$this->Auth->authorize();
}
}
但是我得到了错误
Error: Class LdapAuthenticate contains 1 abstract method and must therefore be declared abstract or implement the remaining methods (BaseAuthorize::authorize)
但是在 CakePHP 文档和说明书中,它指示我设置它的方式,我让 LdapAuthetnticate 扩展 BaseAuthorise 并带有一个用于身份验证的函数,该函数可以根据用户是否登录返回一个 false 对象。
谁能指出为什么会产生这个错误?
【问题讨论】:
-
你把authorization和authentication弄混了。
-
两者都离不开彼此。
标签: php cakephp authentication ldap cakephp-2.0