[英]CakePHP Authenticate with LDAP
I have extended BaseAuthorise in CakePHP and created a new class named LdapAuthenticate, this is located within my /app/Controller/Component/Auth/LdapAuthenticate and it currently looks like this 我在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...";
}
}
Within my AppControl I have 在我的AppControl中,
public $components = array(
'Session',
'Auth' => array(
'loginRedirect' => array('controller' => 'posts', 'action' => 'index'),
'logoutRedirect' => array('controller' => 'pages', 'action' => 'display', 'home'),
'authenticate' => array('Ldap')
)
);
And then within my login method I have 然后在我的登录方法中
public function login() {
if ($this->request->is('post')) {
$this->Auth->authorize();
}
}
However I am getting the error 但是我得到了错误
Error: Class LdapAuthenticate contains 1 abstract method and must therefore be declared abstract or implement the remaining methods (BaseAuthorize::authorize)
However in the CakePHP documentation and cookbook it instructs me to set it up the way I have LdapAuthetnticate extends BaseAuthorise with a function for authenticate which can return an object of false depending on if the user logged in or not. 但是,在CakePHP文档和食谱中,它指示我按照LdapAuthetnticate扩展BaseAuthorise的方式进行设置,并带有用于进行身份验证的函数,该函数可以返回false对象,具体取决于用户是否登录。
Can anybody suggest why this error is being produced? 有人可以建议为什么会产生此错误吗?
您已经扩展了抽象类-因此您必须提供自己的抽象方法实现-在这种情况下,您必须实现:
authorize ( array $user , CakeRequest $request )
as ndm says you are extending BaseAuthorize
but what you want is BaseAuthenticate
正如ndm所说,您正在扩展
BaseAuthorize
但您想要的是BaseAuthenticate
class LdapAuthenticate extends BaseAuthenticate
{
public function authenticate(CakeRequest $request, CakeResponse $response)
{
// ....
return $userData;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.