Symfony2中的security.yml无法进行身份验证

时间:2015-03-11 09:27:46

标签: symfony

我的Symfony应用程序无法在安全目录中正常运行。我输入我的用户并通过,窗口一次又一次打开。由于用户或通行证有误...这是我正在使用的代码。

security:
    firewalls:
        secured_area:
            pattern:    ^/
            anonymous: ~
            http_basic:
                realm: "Secured Area"

    providers:
        in_memory:
            memory:
                users:
                    louis: { password: louispass, roles: [ 'ROLE_ADMIN' ] }

    role_hierarchy:
        ROLE_ADMIN:       ROLE_USER
        ROLE_SUPER_ADMIN: [ROLE_ADMIN, ROLE_ALLOWED_TO_SWITCH]

    access_control:
        - { path: ^/backend, roles: ROLE_USER }
        - { path: ^/backend$, roles: ROLE_USER }

    encoders:
        Symfony\Component\Security\Core\User\User: plaintext

1 个答案:

答案 0 :(得分:0)

  1. {路径:^ / backend $,角色:ROLE_USER} - 仅... / backend

  2. {路径:^ /后端,角色:ROLE_USER} - 其他... /后端......

    1. 路径:^ /后端,角色: ROLE_ADMIN
    2. 尝试:

      security:
          firewalls:
              secured_area:
                  pattern:    ^/
                  anonymous: ~
                  http_basic:
                      realm: "Secured Area"
      
          providers:
              in_memory:
                  memory:
                      users:
                          louis: { password: louispass, roles: 'ROLE_ADMIN' }
      
          role_hierarchy:
              ROLE_ADMIN:       ROLE_USER
              ROLE_SUPER_ADMIN: [ROLE_ADMIN, ROLE_ALLOWED_TO_SWITCH]
      
          access_control:
              - { path: ^/backend, roles: ROLE_ADMIN }
      
      
          encoders:
              Symfony\Component\Security\Core\User\User: plaintext
      

      遇到问题:documentation

      所有用户 - {路径:^ /登录表单,角色: IS_AUTHENTICATED_ANONYMOUSLY }