Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

php

symfony

I have downloaded and installed the Symfony2 standard edition. I've done all the steps detailed in the github readme to remove the AcmeBundle that serves as a demo to the framework. 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:

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?

like image 485
Major Productions Avatar asked Oct 23 '12 01:10

Major Productions


2 Answers

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 }
like image 66
Paulo Vitor Reis Avatar answered Oct 21 '22 22:10

Paulo Vitor Reis


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.

like image 10
Tamara Wijsman Avatar answered Oct 21 '22 23:10

Tamara Wijsman