LexikJwtBudle Symfony 2.8
Я использовал LexikjwtBundle самостоятельно и несколько провайдеров, читая это здесь https://github.com/lexik/LexikJWTAuthenticationBundle
Итак, как настроить мой маршрут?
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%'
Безопасность:
providers:
artibip_users:
id: sm.provider.user
artibip_students:
id: sm.provider.students
firewalls:
login:
pattern: ^/api/login
stateless: true
anonymous: true
form_login:
provider: artibip_users
check_path: /api/login_check
success_handler: lexik_jwt_authentication.handler.authentication_success
failure_handler: lexik_jwt_authentication.handler.authentication_failure
require_previous_session: false
firewalls:
login:
pattern: ^/api/login
stateless: true
anonymous: true
form_login:
provider: artibip_students
check_path: /api/login_check/students
username_path: email
password_path: password
success_handler: lexik_jwt_authentication.handler.authentication_success
failure_handler: lexik_jwt_authentication.handler.authentication_failure
require_previous_session: false
Маршрутизация:
api_login_check_students:
path: /api/login_check/students
ошибка: не найден маршрут для "POST /api/login_check/ Students
если кто-нибудь может предложить мне трек, спасибо
2 ответа
security:
encoders:
BlaBundle\Entity\User: sha512
# https://symfony.com/doc/current/security.html#b-configuring-how-users-are-loaded
providers:
bla_users:
id: provider.user
bla_students:
id: provider.students
firewalls:
login:
pattern: ^/api/login
stateless: true
anonymous: true
form_login:
provider: bla_users
check_path: /api/login_check
success_handler: lexik_jwt_authentication.handler.authentication_success
failure_handler: lexik_jwt_authentication.handler.authentication_failure
require_previous_session: false
artisanlogin:
pattern: ^/api/students/login
stateless: true
anonymous: true
form_login:
provider: bla_students
check_path: /api/students/login_check
success_handler: lexik_jwt_authentication.handler.authentication_success
failure_handler: lexik_jwt_authentication.handler.authentication_failure
require_previous_session: false
security:
encoders:
BlaBundle\Entity\User: sha512
# https://symfony.com/doc/current/security.html#b-configuring-how-users-are-loaded
providers:
bla_users:
id: provider.user
bla_students:
id: provider.students
firewalls:
login:
pattern: ^/api/login
stateless: true
anonymous: true
form_login:
provider: bla_users
check_path: /api/login_check
success_handler: lexik_jwt_authentication.handler.authentication_success
failure_handler: lexik_jwt_authentication.handler.authentication_failure
require_previous_session: false
artisanlogin:
pattern: ^/api/students/login
stateless: true
anonymous: true
form_login:
provider: bla_students
check_path: /api/students/login_check
success_handler: lexik_jwt_authentication.handler.authentication_success
failure_handler: lexik_jwt_authentication.handler.authentication_failure
require_previous_session: false
Решение
security:
encoders:
Artibip\ServiceBundle\Donnees\DomainObject\User: sha512
# https://symfony.com/doc/current/security.html#b-configuring-how-users-are-loaded
providers:
bla_users:
id: provider.user
bla_students:
id: provider.students
firewalls:
login:
pattern: ^/api/login
stateless: true
anonymous: true
form_login:
provider: bla_users
check_path: /api/login_check
success_handler: lexik_jwt_authentication.handler.authentication_success
failure_handler: lexik_jwt_authentication.handler.authentication_failure
require_previous_session: false
artisanlogin:
pattern: ^/api/students/login
stateless: true
anonymous: true
form_login:
provider: bla_students
check_path: /api/students/login_check
success_handler: lexik_jwt_authentication.handler.authentication_success
failure_handler: lexik_jwt_authentication.handler.authentication_failure
require_previous_session: false