2015-05-03 21 views
1

我的Symfony2应用程序存在一个大问题。 我用FosRestBundle,FosUserBundle和LexikJWTAuthenticationBundle创建了RestFul Api。 在我的电脑上,没问题,验证效果很好。 但是,当我在OVH共享服务器上(perf1)上传整个应用程序时,开发环境仍然可用,但不是产品。它说不好的凭据... 我使用邮递员尝试。Symfony2 - 在产品模式下验证失败

我security.yml如下:

security: 
encoders: 
    FOS\UserBundle\Model\UserInterface: 
     algorithm:   pbkdf2 
     hash_algorithm:  sha512 
     encode_as_base64:  true 
     iterations:   1000 

role_hierarchy: 
    ROLE_ADMIN:  ROLE_USER 
    ROLE_SUPER_ADMIN: ROLE_ADMIN 

providers: 
    fos_userbundle: 
     id: fos_user.user_provider.username_email 

firewalls: 
    login: 
     pattern: ^/auth/login 
     stateless: true 
     anonymous: true 
     form_login: 
      provider: fos_userbundle 
      check_path:    /auth/login 
      success_handler:   lexik_jwt_authentication.handler.authentication_success 
      failure_handler:   lexik_jwt_authentication.handler.authentication_failure 
      require_previous_session: false 
      username_parameter: username 
      password_parameter: password 
      post_only:  true 

    api_open: 
     pattern: ^/api/open 
     anonymous: true 
     stateless: true 
     lexik_jwt: ~ 

    api_secured: 
     pattern: ^/api 
     anonymous: false 
     stateless: true 
     lexik_jwt: ~ 

access_control: 

我已经清除和热身督促缓存。

你知道它从哪里来的吗?

谢谢。

+0

在你的web/app.php文件中,尝试$ kernel = new AppKernel('prod',true);调试设置可能会给你一个线索。 – Cerad

+0

它不显示错误... – user3100287

+0

但它在共享服务器上的开发工作?一个神秘的位。 – Cerad

回答

0

这是因为apache会从您的请求中剥离您的Authorization标头。 我的解决方法是在你的网页文件夹中添加这在你的.htaccess或任何阿帕奇可以加载它:

<IfModule mod_rewrite.c> 
    RewriteCond %{HTTP:Authorization} ^(.*) 
    RewriteRule .* - [e=HTTP_AUTHORIZATION:%1] 
</IfModule> 

/\不要忘了激活阿帕奇(谷歌,如果你不URL重写!知道我的意思)