php – Symfony安全基本身份验证

前端之家收集整理的这篇文章主要介绍了php – Symfony安全基本身份验证前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
从symfony book http://symfony.com/doc/current/book/security.html#security-authorization我试图建立基本的http身份验证.

security.yml文件如下所示:

security:
    providers:
        in_memory:
            memory: ~

    firewalls:
        dev:
            pattern: ^/(_(profiler|wdt|error)|css|images|js)/
            security: false

        default:
            anonymous: ~
            http_basic: ~

        access_control:
            - { path: ^/login,roles: ROLE_USER }

但是只要我补充一下

access_control:
        - { path: ^/login,roles: ROLE_USER }

我得到一个symfony错误说:

InvalidConfigurationException in ArrayNode.PHP line 309:
Unrecognized option "0" under "security.firewalls.access_control"

我究竟做错了什么?该怎么做才能修复它?

你的缩进不好

access_control密钥不能保留在防火墙节点下

您应该按如下方式修改security.yml

security:
    providers:
        in_memory:
            memory: ~

    firewalls:
        dev:
            pattern: ^/(_(profiler|wdt|error)|css|images|js)/
            security: false

        default:
            anonymous: ~
            http_basic: ~

    access_control:
        - { path: ^/login,roles: ROLE_USER }

猜你在找的PHP相关文章