简体   繁体   English

Symfony2 - 删除AcmeBundle演示会导致安全提供程序错误

[英]Symfony2 - Removing the AcmeBundle demo results in a security provider error

I have downloaded and installed the Symfony2 standard edition. 我已经下载并安装了Symfony2标准版。 I've done all the steps detailed in the github readme to remove the AcmeBundle that serves as a demo to the framework. 我已经完成了github自述文件中详述的所有步骤,以删除作为框架演示的AcmeBundle。 When attempting to access the console to double check my routes: 尝试访问控制台以仔细检查我的路由时:

$ php app/console router:debug

I get the following error: 我收到以下错误:

[Symfony\Component\Config\Definition\Exception\InvalidConfigurationException]  
The child node "providers" at path "security" must be configured. 

When I undelete security.providers in my security.yml file, so I'm left with: 当我在security.yml文件中取消删除security.providers时,我留下了:

jms_security_extra:
    secure_all_services: false
    expressions: true

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

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

    providers:
        in_memory:
            memory:
                users:
                    user: { password: userpass, roles: [ 'ROLE_USER' ] }
                    admin: { password: adminpass, roles: [ 'ROLE_ADMIN' ] }

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

    access_control:
        #- { path: ^/login, roles: IS_AUTHENTICATED_ANONYMOUSLY, requires_channel: https }
        #- { path: ^/_internal/secure, roles: IS_AUTHENTICATED_ANONYMOUSLY, ip: 127.0.0.1 }

I get a different but similar error: 我得到一个不同但相似的错误:

[InvalidArgumentException]                          
You must at least add one authentication provider.

I'm not sure what to do to fix it. 我不知道该怎么做才能解决它。 Any solutions? 有解决方案吗

You need the provides, like this config: 你需要提供,像这样的配置:

jms_security_extra:
    secure_all_services: false
    expressions: true

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

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

    providers:
        in_memory:
            memory:
                users:
                    user:  { password: userpass, roles: [ 'ROLE_USER' ] }
                    admin: { password: adminpass, roles: [ 'ROLE_ADMIN' ] }

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

        login:
            security: false

        secured_area:
            anonymous: ~

    access_control:
        #- { path: ^/login, roles: IS_AUTHENTICATED_ANONYMOUSLY, requires_channel: https }
        #- { path: ^/_internal/secure, roles: IS_AUTHENTICATED_ANONYMOUSLY, ip: 127.0.0.1 }

For me, the minimal file I could obtain that works without exceptions is: 对我来说,我可以获得的无异常的最小文件是:

security:
    firewalls:
        anonymous:
            anonymous: ~

    providers:
        in_memory:
            memory:

Symfony 2.3.3. Symfony 2.3.3。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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