Symfony 4 + API Plantform +LexikJWTAuthenticationBundle 错误凭证

Symfony 4 + API Plantform +LexikJWTAuthenticationBundle Bad Credential

下午好。请让我在 symfony 4 api 项目中使用 LexikJWTAuthenticationBundle。我正在为 Doctrine 使用 UserProvider。

配置 Doctrine User Provider 后,我安装并配置了 LexikJWTAuthenticationBundle。但是,当我尝试在 url http://localhost:8000/api/login_check 上使用 Postman 进行验证时,这个 JSON {"username":"ak", "password":"ak"} 我有这个错误:{ "code": 401, "message": "Bad credentials" }. 请参阅下面我的 Security.yaml 配置文件。我读过论坛试图解决这个问题,但我还没有找到解决方案。你能帮帮我吗?

security:
encoders:
    App\Entity\Utilisateur:
        algorithm: bcrypt

providers:
    #in_memory: { memory: ~ }
    our_db_provider:
        entity:
            class: App\Entity\Utilisateur

firewalls:
    dev:
        pattern: ^/(_(profiler|wdt)|css|images|js)/
        security: false
    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

    main:
        pattern:    ^/
        user_checker: App\Security\UtilisateurChecker
        anonymous: true
        provider: our_db_provider         

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

你在installation期间是否遗漏了一个配置?我没有看到词典:

lexik_jwt_authentication:
    secret_key:       '%kernel.project_dir%/config/jwt/private.pem' # required for token creation
    public_key:       '%kernel.project_dir%/config/jwt/public.pem'  # required for token verification
    pass_phrase:      'your_secret_passphrase' # required for token creation, usage of an environment variable is recommended
    token_ttl:        3600

大家早上好。我找到了我的问题的解决方案。事实上,我输入了错误的用户密码。

为了解决这篇文章,我使用了这篇文章https://numa-bord.com/miniblog/symfony-4-les-base-dune-gestion-des-utilisateurs-inscription-connexion-droits-dacces/ 我已经使用文章中实现的创建用户命令创建了 au 数据库用户。

在我成功连接到之前创建的用户之后。 ApiPlatform 为我生成一个网络令牌。

非常感谢