php - 如何将 CakeDc\Auth 与未经验证的允许操作一起使用?
问题描述
对于 CakePHP 4.0 和CakeDc\Auth 6.0,我尝试使用中间件实现(而不是组件)设置基于 RBAC 的权限应用程序。
一切正常,除了无需身份验证即可访问的操作(如/login
、/logout
、/recover
)。
在Authentication docs之后,我在我的 中包含了该操作UsersController::beforeFilter
,但我得到了异常:ROOT/vendor/cakephp/authorization/src/Middleware/RequestAuthorizationMiddleware.php
$identity = $request->getAttribute($this->getConfig('identityAttribute'));
$result = $service->canResult($identity, $this->getConfig('method'), $request);
if (!$result->getStatus()) {
throw new ForbiddenException($result); <---- That line
}
return $handler->handle($request);
}
我的Application.php
基本设置在这里:https ://gist.github.com/CauanCabral/27bdb295f7854116e875e4b0c4471289
我错过了什么?
解决方案
推荐阅读
- ionic-framework - ionic:标签输入标签输入一行
- android - 删除持有 Intent 的 ClipData 会产生 BadParcelableException
- database - 我可以在 Access 的 SWITCH 函数中使用 AND 吗?
- linux - 如何为重复用户名的每个实例添加 +1 的增量
- windows - 如何将环境变量的名称作为参数传递?
- github - 发布第一个 github 页面时 URL 未加载
- r - R用动态值对数据框列行进行子集化
- php - 表格排序器在 Ajax、PHP 中不起作用
- html - 如何在上面的文字上添加图片
- google-chrome-extension - chrome.runtime.onmessage 和 chrome.runtime.port onmessage 事件之间的区别