symfony - 无法使用多个提供商和防火墙注销 Symfony 5
问题描述
我必须处理 2 种类型的身份验证(对于管理员部分和客户部分)我确实成功地使用 2 个单独的提供者和 2 个单独的身份验证页面制作了 2 个单独的身份验证器,2 个表单连接正常工作。但我面临一个关于注销操作的问题。
这是security.yaml
示例:
firewalls:
dev:
pattern: ^/(_(profiler|wdt)|css|images|js)/
security: false
customer:
pattern: ^/profile|/login
entry_point: App\Security\CustomerAuthenticator
provider: app_customer_provider
custom_authenticator: App\Security\CustomerAuthenticator
logout:
path: app_logout
target: /
invalidate_session: true
administrator:
pattern: ^/admin|/accessadmin
entry_point: App\Security\AdminAuthenticator
lazy: true
provider: app_admin_provider
custom_authenticator: App\Security\AdminAuthenticator
logout:
path: app_logout
target: /
invalidate_session: true
这是 SecurityController.php 中的注销功能
/**
* @Route("/logout", name="app_logout")
*/
public function logout()
{
throw new \LogicException('This method can be blank - it will be intercepted by the logout key on your firewall.');
}
当我尝试访问 /logout URL 时,我实际上抛出了异常(好吧,你会说它是这样编码的)。问题是,如果通过“主要”属性重命名防火墙之一,在这种情况下,注销功能可以完美运行。
我不知道此时我缺少什么...如果无论如何调用注销功能,是否有解决方案可以使用我将放入公共功能的任何功能强制注销logout()
?
解决方案
推荐阅读
- reactjs - 避免详尽深度警告的 useEffect 方法
- java - 尝试通过 Firebase 接收推送通知时,Android 应用程序崩溃
- reactjs - 在刷新中断时反应路由器
- php - 基于键的多数组div
- anylogic - 有没有办法返回代理与其目的地之间的网络中的节点列表?
- reactjs - 使用 React 以不同的角色和验证登录
- c - 如果我将代码添加到(不相关的)打印部分,“用于测量执行周期的双线程计数器模型”会更改输出
- c# - 有没有办法使用 WPF 的箭头键移动图片?
- angular - 观察反应角度形式的原始状态时的问题
- django - 显示可能不存在的对象的页面?