gpt4 book ai didi

symfony - LexikJWTAuthenticationBundle - 无法找到路径 "/api/login_check"的 Controller 。路由配置错误

转载 作者:行者123 更新时间:2023-12-05 06:31:39 28 4
gpt4 key购买 nike

我使用类似文档的配置。这是我的安全文件:

security:
encoders:
FOS\UserBundle\Model\UserInterface: sha512

role_hierarchy:
ROLE_ADMIN: [ROLE_USER]

providers:
fos_userbundle:
id: fos_user.user_provider.username

firewalls:
login:
pattern: ^/api/login
stateless: true
anonymous: true
json_login:
check_path: /api/login_check
success_handler: lexik_jwt_authentication.handler.authentication_success
failure_handler: lexik_jwt_authentication.handler.authentication_failure

api:
pattern: ^/api
provider: fos_userbundle
stateless: true
guard:
authenticators:
- lexik_jwt_authentication.jwt_token_authenticator

access_control:
- { path: ^/api/login_check, roles: IS_AUTHENTICATED_ANONYMOUSLY }
- { path: ^/api, roles: IS_AUTHENTICATED_FULLY }

还有我的路由文件

api_login_check:
path: /api/login_check

当我在浏览器中访问/api/login_check 时出现错误

Unable to find the controller for path "/api/login_check". The route is wrongly configured.

有什么想法吗?

最佳答案

使用以下内容更改您的 security.yml 登录防火墙配置:

login:
pattern: ^/api/login
stateless: true
anonymous: true
form_login:
check_path: /api/login_check
success_handler: lexik_jwt_authentication.handler.authentication_success
failure_handler: lexik_jwt_authentication.handler.authentication_failure

从您的访问控制中删除 login_check 路径,它应该已经配置好

- { path: ^/api/login_check, roles: IS_AUTHENTICATED_ANONYMOUSLY }

关于symfony - LexikJWTAuthenticationBundle - 无法找到路径 "/api/login_check"的 Controller 。路由配置错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51730963/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com