【发布时间】:2018-01-29 09:02:01
【问题描述】:
我有 Apache 服务器和 Postman 来检查 api url 是否正常工作并且我有奇怪的行为,这意味着当我在 Postman 上使用正确的凭据 http://localhost/xxx/web/app_dev.php/api/login_check 调用时,LexikJwtBundle 正在返回令牌,所以我一切正常。
但是在 mozilla 或 Chrome 中这样做我得到401 Bad Credentials,我的security.yml
security:
encoders:
FOS\UserBundle\Model\UserInterface: bcrypt
role_hierarchy:
ROLE_ADMIN: ROLE_USER
ROLE_SUPER_ADMIN: ROLE_ADMIN
providers:
fos_userbundle:
id: fos_user.user_provider.username
firewalls:
login:
pattern: ^/api/login
stateless: true
anonymous: true
provider: fos_userbundle
form_login:
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
api:
pattern: ^/api
stateless: true
lexik_jwt: ~
main:
pattern: ^/
form_login:
provider: fos_userbundle
# csrf_provider: security.csrf.token_manager # Use form.csrf_provider instead for Symfony <2.4
csrf_token_generator: security.csrf.token_manager
logout: true
anonymous: true
Mozilla 中的请求:
Host: localhost
User-Agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:58.0) Gecko/20100101 Firefox/58.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-US,en;q=0.5
Accept-Encoding: gzip, deflate
Access-Control-Request-Method: POST
Access-Control-Request-Headers: content-type
Origin: http://sprawy.com
Connection: keep-alive
有什么问题吗?
【问题讨论】:
-
只检查请求头,希望你能得到答复
-
字段名称可能有误。
标签: php symfony lexikjwtauthbundle