2

这是我的安全防火墙配置:

firewalls:
    # Disabling the security for the web debug toolbar, the profiler and Assetic.
    dev:
        pattern:  ^/(_(profiler|wdt)|css|images|js)/
        security: false

    # -> custom firewall for the admin area of the URL
    qis:
        pattern:            /qis(.*)
        context:            user
        form_login:
            provider:       fos_userbundle
            login_path:     /login
            check_path:     /qis/login_check
        logout:
            path:           /qis/logout
        anonymous:          false

    # This firewall is used to handle the public login area
    # This part is handled by the FOS User Bundle
    main:
        pattern:             .*
        context:             user
        form_login:
            provider:       fos_userbundle
            login_path:     /login
            use_forward:    true
            default_target_path: /qis
            #always_use_default_target_path: false
            check_path:     /login_check
            failure_path:   null
        logout:
            path:           /logout
        anonymous:          true

        # Session liftime
        remember_me:
            key: '%secret%'
            lifetime: 28800

        # Sonata User Impersonating
        switch_user: true

完整配置:security.yml

这些是按预期工作的用例:

  1. 当直接访问登录页面 /login 时,用户被正确地重定向到 default_target_path qis/。
  2. 当访问一个页面时,例如 /contract 用户被正确地重定向回这个请求的页面。

我想使用qis防火墙实现2中提到的相同行为。

但:

当通过 qis 路由访问时,例如http://localhost:8000/qis/contract/list,它不会重定向到相同的链接,而是再次重定向到 default_target_path qis/。

qis防火墙需要哪些设置?

4

1 回答 1

2

试试这个配置:

 admin:
        pattern:      /qis(.*)
        form_login:
            provider:       fos_userbundle
            login_path:     sonata_user_admin_security_login
            use_forward:    true
            use_referer: true
            check_path:     sonata_user_admin_security_check
            failure_path:   null
        logout:
            path:           sonata_user_admin_security_logout
        anonymous:    true

您需要将匿名设置为 true 以允许用户进行身份验证。登录页面必须具有公共访问权限。

于 2015-02-03T13:12:27.307 回答