我请求时,在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