使用LexikJWTAuthenticationBundle 2.4生成令牌Symfony flex

时间:2018-05-02 07:42:46

标签: symfony lexikjwtauthbundle

我刚用LexikJWTAuthenticationBundle2.4测试了symfony flex,我跟着here

错误是 NotFoundHttpException 无法找到路径" / login_check"的控制器。路线配置错误。

我必须创建一个控制器吗?不确定! 或者是什么样的愚蠢

这是我的安全文件:



security:
    encoders:
        App\Entity\User: 
            algorithm: bcrypt
  
    providers:
        entity_provider:
            entity:
                class: App\Entity\User
                property: username
       
        users:
            id: App\Metier\Provider\UserProvider
        
    firewalls:
        login:
            pattern:  ^/login
            stateless: true
            anonymous: true
            json_login:
                provider: users
                check_path:    /login_check
                success_handler:                  lexik_jwt_authentication.handler.authentication_success
                failure_handler:          lexik_jwt_authentication.handler.authentication_failure


        register:
            pattern:  ^/register
            stateless: true
            anonymous: true
        api:
            pattern:   ^/api
            stateless: true
            provider: entity_provider
            anonymous: false
            guard:
                authenticators:
                    - lexik_jwt_authentication.jwt_token_authenticator

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




我的route.yml和我的私钥:



api_login_check:
        path: /login_check

 -----BEGIN RSA PRIVATE KEY-----
Proc-Type: 4,ENCRYPTED
DEK-Info: AES-256-CBC,1F2589373C3622EADA0262E3D18FBA51




提前感谢您的帮助

1 个答案:

答案 0 :(得分:0)

我解决了我的问题,因为我在防火墙中使用了 json_login,所以我们必须这样做以便与邮递员进行身份验证:



{
	"username":"bla",
	"password":"blabla"
}