0

我目前正在为我的网站开发一个 Restfull API。我决定将其开发为插件。

我正在使用扩展的自定义类BasicAuthentification。它允许我检查客户端应用程序的凭据,以便将 API 的使用限制为只有经过批准的开发人员。

此文件在添加到 CakePHP CORE 时完美运行:Cake/Controller/Component/Auth/DeviceAuthentification.php

由于我正在开发一个插件,我希望所有内容都在同一个目录中。因此,在我的插件目录中MyApi,我在以下路径中添加了我的自定义类:

MyApi/Controller/Auth/DeviceAuthentification.php

为了加载它,在我的插件控制器MyApiAppController中,我添加了以下代码:

public $components = array(
    'Auth' => array(
        'authenticate' => 'Device', // I also tried MyApi.Device
        'sessionKey' => false
    )

);

它不加载,错误如下:

未找到身份验证适配器“设备”。

有人有想法吗?

4

1 回答 1

2

好吧,在查看了核心文件 AuthComponent 之后,您似乎需要具有以下路径:

MyApi/Controller/组件/Auth/DeviceAuthentification.php

代替

MyApi/Controller/Auth/DeviceAuthentification.php

因此,无论何时在Plugin 目录下工作,都需要添加目录Component

于 2013-10-30T16:03:58.260 回答