首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >Symfony 4.2: LexikJWT:无法找到路径"/api/login_check“的控制器。路由配置错误

Symfony 4.2: LexikJWT:无法找到路径"/api/login_check“的控制器。路由配置错误
EN

Stack Overflow用户
提问于 2019-01-11 06:45:01
回答 1查看 1.3K关注 0票数 1

欢迎使用我的第一篇堆栈文章:)

php 7.2 symfony 4.2上的问题。我两天都想不出这件事。

当我尝试通过POST /api/login_check访问头文件Content-Type application/json时,我得到了以下日志。

代码语言:javascript
运行
复制
2019-01-10T23:33:11+01:00 [info] Matched route "api_login_check".
2019-01-10T23:33:11+01:00 [info] Populated the TokenStorage with an anonymous Token.
2019-01-10T23:33:11+01:00 [warning] Unable to look for the controller as the "_controller" parameter is missing.
2019-01-10T23:33:11+01:00 [error] Uncaught PHP Exception Symfony\Component\HttpKernel\Exception\NotFoundHttpException: "Unable to find the controller for path "/api/login_check". The route is wrongly configured." at /home/mateusz/Workspace/api-platform/vendor/symfony/http-kernel/HttpKernel.php line 134
[Thu Jan 10 23:33:11 2019] 127.0.0.1:56616 [404]: /api/login_check

我的配置:

代码语言:javascript
运行
复制
security:
    encoders:
        App\Entity\User: bcrypt
    providers:
        database:
            entity:
                class: App\Entity\User
                property: username
    firewalls:
        dev:
            pattern: ^/(_(profiler|wdt)|css|images|js)/
            security: false
        main:
            anonymous: true
        api:
            pattern: ^/api
            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
            guard:
                authenticators:
                    - lexik_jwt_authentication.jwt_token_authenticator

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

/routes中的路径定义为: api_login_check: jwt.yaml : /api/login_check

非常感谢您的帮助:)

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2019-01-14 23:39:24

移走或放在底部:

代码语言:javascript
运行
复制
main:
    anonymous: true

由于该条目,路由器永远无法获取您的api防火墙。

票数 4
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/54137981

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档