我有 Apache 服务器和 Postman 来检查 api url 是否正常工作并且我有奇怪的行为,这意味着当我http://localhost/xxx/web/app_dev.php/api/login_check
在 Postman 上使用正确的凭据调用时,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
有什么问题?