【发布时间】:2019-01-27 14:42:57
【问题描述】:
下午好。请我在 symfony 4 api 项目中使用 LexikJWTAuthenticationBundle。我正在将 UserProvider 用于 Doctrine。
在配置 Doctrine User Provider 之后,我已经安装并配置了 LexikJWTAuthenticationBundle。但是,当我尝试在 url http://localhost:8000/api/login_check 上使用 Postman 验证这个 JSON {"username":"ak", “密码”:“ak”}我有这个错误:{ “代码”:401, “消息”:“凭据错误” }。 请参阅下面我的 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 }
【问题讨论】:
标签: symfony lexikjwtauthbundle