开发者

Symfony2 Security problem

i'm going to adapt my web project (based on symfony2 PR5) to symfony2 PR7. Everything is pretty clear with this migration except the Security bundle. Here is my security configuration:

security:
    encoders:
        Application\PermissionsBundle\Entity\Stuff: sha1
    providers:
        main:
            entity: { class: PermissionsBundle:Stuff, property: username}
    firewalls:
        main:
            pattern: .*
            form_login:
                check_path:   /login-check-admin
                login_path:   /login-admin
                failure_path: /login-admin
            logout:     true
            anonymous: true 
        backend:
            pattern: /a开发者_如何学编程dmin.*
            form_login:
                check_path: /login-check-admin
                login_path: /login-admin
            logout: true
            security: true
            anonymous: false
    access_control:
        - { path: /admin.*, role: ROLE_ADMIN }

Routing configuration:

_security_login:
    pattern: /login-admin
    defaults: { _controller: PermissionsBundle:Security:login }

_security_check:
    pattern: /login-check-admin

_security_logout:
    pattern: /logout-admin

_security_status:
    pattern: /sec_status
    defaults: { _controller: PermissionsBundle:Security:status }

_security_get_username:
    pattern: /security/get/username
    defaults: { _controller: PermissionsBundle:Security:getUserName }

When I try to authenticate, I get a 404 fpr login checking: Firebug output: http://impic.ru/uploads/2011/2303/53849205_61601933.jpeg

Can anybody please help me with this problem? This code works fine in PR5, but not in PR7. Official symfony documentation hasn't changed yet. Maybe I'm missing something?


The solution is simple. You cannot customize logout and login_check routing patterns. It means that your security.yml file should looks like this:

form_login:
    check_path:   /login_check
    login_path:   /login

and your routing.yml file should looks like this:

_security_check:
    pattern: /login_check
_security_logout:
    pattern: /logout

These work perfect for me.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜