json 身份验证如何与 symfony 一起工作?

How json authentication works with symfony?

我不知道是什么阻塞了。我一直在关注 symfony 文档。

/security.yaml

security:
# https://symfony.com/doc/current/security.html#registering-the-user-hashing-passwords
password_hashers:
    Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface: 'auto'
    # https://symfony.com/doc/current/security.html#loading-the-user-the-user-provider
providers:
    # users_in_memory: { memory: null }
    app_user_provider:
        entity:
            class: App\Entity\User
            property: email
firewalls:
    dev:
        pattern: ^/(_(profiler|wdt)|css|images|js)/
        security: false
    main:
        #lazy: true
        provider: app_user_provider
        json_login:
            # api_login is a route we will create below
            check_path: api_login
            #username_path: email
            #password_path: password
            #username_path: security.credentials.email
            #password_path: security.credentials.password

/controller/ApiLoginController.php

#[Route('/login', name: 'app_api_login', methods: 'POST')]
public function index(#[CurrentUser] ?User $user): Response
{
    dd($user);
}

我在 header 的请求中设置了 Content-Type application/json 并且我在 body 中输入了 json {"username": "toto@toto.com","password": "root"} 和我 post 与 postman.

的请求

我得到的回复总是空的...欢迎您的帮助

好的我改

check_path: api_login

来自

check_path: app_api_login

check_path 必须与姓名相同:'app_api_login' 我的天啊....