Symfony2安全问题

时间:2011-03-23 13:25:08

标签: security authentication symfony

我要将我的网络项目(基于symfony2 PR5)改编为symfony2 PR7。除了安全捆绑之外,此迁移的一切都非常清楚。这是我的安全配置:

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: /admin.*
            form_login:
                check_path: /login-check-admin
                login_path: /login-admin
            logout: true
            security: true
            anonymous: false
    access_control:
        - { path: /admin.*, role: ROLE_ADMIN }

路由配置:

_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 }

当我尝试进行身份验证时,我会收到404 fpr登录检查: Firebug输出:http://impic.ru/uploads/2011/2303/53849205_61601933.jpeg

任何人都可以帮我解决这个问题吗?此代码在PR5中工作正常,但在PR7中没有。官方symfony文档尚未更改。也许我错过了什么?

1 个答案:

答案 0 :(得分:1)

解决方案很简单。您无法自定义logout和login_check路由模式。这意味着您的security.yml文件应如下所示:

form_login:
    check_path:   /login_check
    login_path:   /login

并且您的routing.yml文件应如下所示:

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

这些工作对我来说很完美。