私は自分のREST API用にjwt authを持っていなければなりません。今はすべて正常に動作しますが、ペアのメール/パスワードでトークンを取得しようとしているときに、エラーが表示されます。私はユーザー名/パスワードを使用するとすべてが大丈夫です。 だから、答えは新しいユーザープロバイダーを追加することでした私のsecurity.ymlFOSUserBundle + LexixJWTAuthBundle電子メールでのログイン
security:
encoders:
FOS\UserBundle\Model\UserInterface: sha512
providers:
fos_userbundle:
id: fos_user.user_provider.username_email
firewalls:
dev:
pattern: ^/(_(profiler|wdt)|css|images|js)/
security: false
api_doc:
pattern: ^/api/doc
anonymous: true
security: false
login:
pattern: ^/login
stateless: true
anonymous: true
form_login:
check_path: /login
username_parameter: username
password_parameter: password
provider: fos_userbundle
success_handler: lexik_jwt_authentication.handler.authentication_success
failure_handler: lexik_jwt_authentication.handler.authentication_failure
require_previous_session: false
api:
pattern: ^/api
stateless: true
guard:
authenticators:
- lexik_jwt_authentication.jwt_token_authenticator
password:
pattern: ^/user/passwords
anonymous: true
security: false
access_control:
- { path: ^/user/passwords, roles: IS_AUTHENTICATED_ANONYMOUSLY }
- { path: ^/api/doc, roles: IS_AUTHENTICATED_ANONYMOUSLY }
- { path: ^/login, roles: IS_AUTHENTICATED_ANONYMOUSLY }
- { path: ^/api, roles: IS_AUTHENTICATED_FULLY }
config.yml
lexik_jwt_authentication:
private_key_path: '%jwt_private_key_path%'
public_key_path: '%jwt_public_key_path%'
pass_phrase: '%jwt_key_pass_phrase%'
token_ttl: '%jwt_token_ttl%'
user_identity_field: email
あなたは多分 'username_parameter変更してみました:電子メールにusername'を? – kunicmarko20
@MarkoKunic私はしようとしましたが、ラベルだけです。私は 'username_parameter:test'と書くことができますが、それは動作しますが、ユーザ名のためのものです:( –
多分これを試してみてくださいhttps://stackoverflow.com/a/21064627 – kunicmarko20