简体   繁体   中英

Secure area in Symfony2

I have a question to the security features of Symfony2. I want to protect a special area of my application under the /my prefix.

My configuration looks like follows:

security.config:
    providers:
        my:
            entity: { class: MyUserBundle:User, property: username }

    firewalls:
        public:
            pattern: /my/login.*
            security: false

        my:
            pattern: /my.*
            form-login:
                check_path: /my/login_check
                login_path: /my/login
            logout: true

    access_control:
        - { path: /my/login.*, roles: IS_AUTHENTICATED_ANONYMOUSLY }

When I try to access the login area, everything works fine, submitting the form leads to an error page, because there is no registered controller for the _security_check route, like its described in the guide :

_security_login:
    pattern: /my/login
    defaults: { _controller: MyUserBundle:Auth:login }

_security_check:
    pattern: /my/login_check

I think normally the SecurityBundle hacks into this process so that no controller is needed. The configuration of Symfony2 is allways very complex.

I think I missed something, hope you can help.
Thanks in advance!

我在symfony用户邮件组的帮助下解决了这个问题。

您必须定义一个防火墙(描述所有路由),并使用设置的access_control部分确定安全区域。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM