激活注销安全配置

时间:2016-03-08 08:43:35

标签: symfony sonata

我有这个问题,我在防火墙中更改了注销配置的位置但总是响应相同,我该怎么办?

我收到此错误:

  

您必须在安全防火墙配置中激活注销

这是我的代码

security:
    firewalls:
        oauth_authorize:
            pattern:    ^/oauth/v2/auth
            form_login:
                provider: fos_userbundle
                check_path: _security_check
                login_path: _demo_login
        oauth_token:
            pattern:    ^/oauth/v2/token
            security:   false
        api:
            pattern:    ^/api
            fos_oauth:  true
            stateless:  true
            anonymous:  false # can be omitted as its default value
        login:
            pattern:  ^/secured/login$
            security: false
        main:
            pattern: ^/
            form_login:
                provider: fos_userbundle
                csrf_provider: form.csrf_provider
                always_use_default_target_path: true
                default_target_path: /profile
        logout:
            path: /user/logout
            anonymous: true
        dev:
            pattern:  ^/(_(profiler|wdt)|css|images|js)/
            security: false
        admin:
            pattern:            /admin(.*)
            context:            user
            form_login:
                provider:       fos_userbundle
                login_path:     /admin/login
                use_forward:    false
                check_path:     /admin/login_check
                failure_path:   null
            logout:
                path:           /admin/logout
            anonymous:          true
        main:
            pattern:             .*
            context:             user
            form_login:
                provider:       fos_userbundle
                login_path:     /login
                use_forward:    false
                check_path:     /login_check
                failure_path:   null
            logout:             true
            anonymous:          true

2 个答案:

答案 0 :(得分:0)

也许试试这个:

dev:
    pattern: ^/(_(profiler|wdt|error)|css|images|js)/
    security: false

main:
    pattern: ^/
    security: true
    switch_user: true
    form_login:
        provider: fos_userbundle
        csrf_provider: form.csrf_provider
        success_handler: fo_security.handler.login_success
        default_target_path: /
    anonymous:    true
    logout:
        path:   /logout
        target: /login
        invalidate_session: true

如果您不使用FOSUserBundle,请不要注意参数。 这个例子尝试了3件事:

  • 之前声明开发防火墙
  • 以不同方式声明注销并使会话无效
  • 当您注销时立即重定向登录页面

答案 1 :(得分:0)

我找到了这个问题的解决方案并且它可以正常运行,问题出在主要配置

 main:      
    pattern: ^/
    security: true
    switch_user: true
    form_login:
        provider: fos_userbundle
        csrf_provider: form.csrf_provider
        default_target_path: /profile
        anonymous:    true
    logout:
        path:   /logout
        target: /login
        invalidate_session: true