symfony 4 json_login JWT 401错误的凭证

时间:2018-12-18 09:10:05

标签: symfony symfony4 lexikjwtauthbundle

我请求时,在401 Bad credential令牌中获取lexik jwt错误:

curl -X POST -H "Content-Type: application/json" http://localhost:8080/api/login_check -d '{"username":"arnav@test.com","password":"123"}'

防火墙设置:

security:

    providers:
        entity_provider:
            entity:
                class: App\Entity\User
                property: username

    encoders:
        App\Entity\User:
            algorithm: bcrypt 
    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
            stateless: true
            guard:
                authenticators:
                    - lexik_jwt_authentication.jwt_token_authenticator

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

路由

api_login_check:
    path: /api/login_check

0 个答案:

没有答案