Php FOSUserBundle从symfony 2.4升级到2.6后无法登录

Php FOSUserBundle从symfony 2.4升级到2.6后无法登录,php,symfony,fosuserbundle,symfony-2.6,Php,Symfony,Fosuserbundle,Symfony 2.6,最近我一直在把我的网站从symfony 2.4升级到2.6。我遵循我找到的所有升级说明,几乎所有的东西都可以找到。但是我现在不能再登录我的网站了。 我使用FOSUserBundle,我的composer.json包含以下内容: "friendsofsymfony/user-bundle": "2.0.*@dev", 我读了所有的教程至少三次,比较了所有的选项,现在我已经把头发拔出来了,因为我找不到一个有效的解决方案 2.4中的一切都很好,因此我认为这可能与security.yml中定义的选项有

最近我一直在把我的网站从symfony 2.4升级到2.6。我遵循我找到的所有升级说明,几乎所有的东西都可以找到。但是我现在不能再登录我的网站了。 我使用FOSUserBundle,我的composer.json包含以下内容:

"friendsofsymfony/user-bundle": "2.0.*@dev",
我读了所有的教程至少三次,比较了所有的选项,现在我已经把头发拔出来了,因为我找不到一个有效的解决方案

2.4中的一切都很好,因此我认为这可能与
security.yml
中定义的选项有关

问题是,我在apache/symfony日志文件中没有得到任何异常、警告或任何可疑信息。 这是我的安全。yml:

parameters:
    security.acl.permission.map.class:
      Sonata\AdminBundle\Security\Acl\Permission\AdminPermissionMap

    sonata.admin.security.mask.builder.class:
      Sonata\AdminBundle\Security\Acl\Permission\MaskBuilder

security:
    acl:
        connection: default
    encoders:
        FOS\UserBundle\Model\UserInterface: sha512
    access_denied_url:    ~
    always_authenticate_before_granting:  false

    role_hierarchy:
        ROLE_ADMIN:       [ROLE_USER, ROLE_SONATA_ADMIN]
        ROLE_SUPER_ADMIN: [ROLE_ADMIN, ROLE_ALLOWED_TO_SWITCH]
        ROLE_AUTHOR:      [ROLE_USER, SONATA]
        SONATA:
          - ROLE_SONATA_PAGE_ADMIN_PAGE_EDIT

    providers:
        fos_userbundle:
            id: fos_user.user_provider.username
        fos_facebook_provider:
            id: fos_facebook.user.login
        chain_provider:
          chain:
            providers: [fos_userbundle, fos_facebook_provider]

    firewalls:
        dev:
            pattern:  ^/(_(profiler|wdt)|css|images|js)/
            security: false
        main:
          pattern:   ^/
          fos_facebook:
            app_url: "http://apps.facebook.com/XXX/"
            server_url: "http://XXX"
            login_path: /user/login
            check_path: /facebook/login_check
            default_target_path: /Account
            provider: fos_facebook_provider
          form_login:
            provider: fos_userbundle
            csrf_provider: form.csrf_provider
            remember_me: true
            login_path:     /user/login
            default_target_path: /Account
            use_forward:    false
            check_path:     /user/login_check
            failure_path:   null
          logout:
            path: /user/logout
          anonymous: true
          provider: main
          context: main_auth
          remember_me:
            key: XXX
            lifetime: XXX
            path: /
            domain: ~

    access_control:
      - { path: ^/user/login$, role: IS_AUTHENTICATED_ANONYMOUSLY }
      - { path: ^/secured, role: ROLE_USER }
      - { path: ^/login$, role: IS_AUTHENTICATED_ANONYMOUSLY }
      - { path: ^/register, role: IS_AUTHENTICATED_ANONYMOUSLY }
#      # The WDT has to be allowed to anonymous users to avoid requiring the login with the AJAX request
      - { path: ^/wdt/, role: IS_AUTHENTICATED_ANONYMOUSLY }
      - { path: ^/profiler/, role: IS_AUTHENTICATED_ANONYMOUSLY }
##      # AsseticBundle paths used when using the controller for assets
      - { path: ^/js/, role: IS_AUTHENTICATED_ANONYMOUSLY }
      - { path: ^/css/, role: IS_AUTHENTICATED_ANONYMOUSLY }

#      # URL of FOSUserBundle which need to be available to anonymous users
#      - { path: ^/secured/.*, role: [ROLE_FACEBOOK] } # This is the route secured with fos_facebook
#      - { path: ^/login$, role: IS_AUTHENTICATED_ANONYMOUSLY }
      - { path: ^/login_check$, role: IS_AUTHENTICATED_ANONYMOUSLY } # for the case of a failed login
      - { path: ^/user/new$, role: IS_AUTHENTICATED_ANONYMOUSLY }
      - { path: ^/user/check-confirmation-email$, role: IS_AUTHENTICATED_ANONYMOUSLY }
      - { path: ^/user/confirm/, role: IS_AUTHENTICATED_ANONYMOUSLY }
      - { path: ^/user/confirmed$, role: IS_AUTHENTICATED_ANONYMOUSLY }
      - { path: ^/user/request-reset-password$, role: IS_AUTHENTICATED_ANONYMOUSLY }
      - { path: ^/user/send-resetting-email$, role: IS_AUTHENTICATED_ANONYMOUSLY }
      - { path: ^/user/check-resetting-email$, role: IS_AUTHENTICATED_ANONYMOUSLY }
      - { path: ^/user/reset-password/, role: IS_AUTHENTICATED_ANONYMOUSLY }
#      - { path: ^/secured/.*, role: [IS_AUTHENTICATED_FULLY] } # This is the route secured with fos_facebook
#      # Secured part of the site
      # This config requires being logged for the whole site and having the admin role for the admin part.
      # Change these rules to adapt them to your needs
      - { path: ^/admin/.*, role: [ROLE_ADMIN, ROLE_SONATA_ADMIN, ROLE_AUTHOR] }
#      - { path: ^/.*, role: IS_AUTHENTICATED_ANONYMOUSLY }
输入凭据后,我会被重定向到
登录检查
url。在这个请求中,我可以看到一个“302”重定向返回到我的登录页面。但我认为这是正常的。之后,我将被重定向到我的登录页面,而无需验证

您看到我的配置中有任何错误吗? 如果你需要更多的代码,请告诉我


app.yml中的FOS配置

fos_user:
    db_driver: orm
    firewall_name: main
    user_class: XXX\UserBundle\Entity\User
    group:
        group_class: XXX\UserBundle\Entity\Group
    service:
      mailer: fos_user.mailer.twig_swift
      user_manager: fos_user.user_manager.default
    registration:
      form:
        type: my_user_registration
      confirmation:
        enabled: true
        template: MyBundle:Mail:registration.email.twig
以细枝形式登入表格

<form class="login_formular" action="{{ path("fos_user_security_check") }}" method="post">
    <input type="hidden" name="_csrf_token" value="{{ csrf_token }}"/>

    <table>
        <tr>
            <td><label for="username">{{ 'security.login.username'|trans({}, 'FOSUserBundle') }}</label></td>
            <td><input class="login_input" type="text" id="username" name="_username" value="{{ last_username }}"
                       required="required"/></td>
        </tr>
        <tr>
            <td><label for="password">{{ 'security.login.password'|trans({}, 'FOSUserBundle') }}</label></td>
            <td><input class="login_input" type="password" id="password" name="_password" required="required"/></td>
        </tr>
        <tr>
            <td><label class="login_input" for="remember_me">Eingeloggt bleiben:</label></td>
            <td><input type="checkbox" id="remember_me" name="_remember_me" value="on" style="margin-top: 5px;"/>
            </td>
        </tr>
        {% if error %}
            <tr>
                <td colspan="2" id="login_form_errors">{{ error.messageKey|trans(error.messageData, 'security') }}</td>
            </tr>
        {% endif %}
        <tr>
            <td colspan="2">
                <input type="submit" id="_submit" name="_submit"
                       value="{{ 'security.login.submit'|trans({}, 'FOSUserBundle') }}"/>
            </td>
        </tr>
    </table>

    <div class="clear"></div>

</form>

{{'security.login.username'| trans({},'FOSUserBundle')}
{{'security.login.password'{}trans({},'FOSUserBundle')}
Eingeloggt bleiben:
{%if错误%}
{{error.messageKey | trans(error.messageData,'security')}
{%endif%}

我认为您正在使用security.yml

{
encoders:
    FOS\UserBundle\Model\UserInterface:
        algorithm: sha512
        encode_as_base64: false
        iterations: 1
}

注释
encode\u as_base64
iterations
,然后它就会解决。

我找到了问题和解决方案,但我对找到它的方式感到失望

我的问题描述缺少导致错误的config.yml

这是我的配置中的故障部分:

framework:
    session:
      save_path: %kernel.root_dir%/var/sessions
      cookie_httponly: true
由于某些原因,我在过去更改了
save\u path
设置并激活了
cookie\u httponly
。 在我看来,这种组合使得框架无法保存任何与客户机相关的数据

但是,我在symfony或apache日志中找不到任何错误,指出
save\u path
下的路径错误且不存在。只有这条消息可以节省我几个小时的搜索时间。最后,我搜索了我的项目git历史记录,查找可能导致问题的配置和源代码中的任何更改

此配置正在运行:

framework:
    session:
      save_path: ~
#      cookie_httponly: true
如果有人知道为什么这些参数阻止登录,我欢迎任何评论