CakePHP 2.x自定义“身份验证适配器"和"LdapAuthorize&"没有找到

编程入门 行业动态 更新时间:2024-10-25 00:33:15
本文介绍了CakePHP 2.x自定义“身份验证适配器"和"LdapAuthorize&"没有找到的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我正在使用CakePHP构建应用程序,并尝试合并自定义身份验证对象,但似乎无法找到它.尝试登录时出现以下错误:未找到身份验证适配器"LdapAuthorize".我已经使用用于身份验证的代码创建了文件app/Controller/Component/Auth/LdapAuthorize.php.在"AppController.php"顶部附近

I'm building an application using CakePHP and trying to incorporate a custom authentication object but it does not seem to be able to find it. I get the following error when I try to log in: "Authentication adapter "LdapAuthorize" was not found". I have created the file app/Controller/Component/Auth/LdapAuthorize.php with my code for my authentication. Near the top of "AppController.php" I have

App::uses('LdapAuthroize', 'Controller/Component/Auth/LdapAuthorize');

在我拥有的AppController类中

and within the AppController class I have

public $components = array( 'Session', 'Auth' => array( 'loginRedirect' => array('controller' => 'pendings', 'action' => 'index'), 'logoutRedirect' => array('controller' => 'users', 'action' => 'login'), 'authorize' => array('Controller'), 'authenticate' => array('LdapAuthorize') ) );

,然后在我的UsersController.php中,具有以下登录功能.

and then in my UsersController.php I have the following login function.

public function login() { if($this->request->is('post')) { if($this->Auth->login()) { // My Login stuff... } else $this->redirect(array('controller'=>'someController', 'action'=>'someAction')); } }

如果有人知道为什么它似乎无法加载很棒的我的自定义身份验证对象.谢谢!

If anyone has any idea why it can't seem to load my custom authentication object that would be awesome. Thanks!

推荐答案

我将自定义身份验证类放在 Controller/Component/Auth 中.例如,我的班级的名称是 CustomUserAuthenticate ,文件的路径是

I put my custom authentication class inside Controller/Component/Auth. For example, the name of my class is CustomUserAuthenticate and the path to the file is,

控制器/组件/Auth/CustomUserAuthenticate.php.

然后在我的 AppController 中,将以下内容添加到 authenticate 数组

Then in my AppController I added the following to the authenticate array,

class AppController extends Controller { public $components = array( 'Auth' => array( /** Any other configuration like redirects can go here */ 'authenticate' => array( 'CustomUser' ) ) ); }

除了 Authenticate 字以外, authenticate 数组中的字符串必须与类的名称匹配.

The string in the authenticate array must match the name of the class except for the Authenticate word.

我的 CustomUserAuthenticate 类扩展了CakePHP的 Controller/Component/Auth/BaseAuthenticate ,并覆盖了 authenticate 方法.CakePHP的文档指出,这不是必填.我没有那样尝试.

My CustomUserAuthenticate class extends CakePHP's Controller/Component/Auth/BaseAuthenticate and overrides the authenticate method. CakePHP's documentation states that this is not required. I haven't tried that way.

更多推荐

CakePHP 2.x自定义“身份验证适配器"和"LdapAuthorize&"没有找到

本文发布于:2023-11-04 00:50:02,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1556505.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:自定义   适配器   没有找到   身份验证   CakePHP

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!