First make sure have the Bundle enabled in your AppKernel. So add this
line:

new Symfony\Bundle\SecurityBundle\SecurityBundle(),


Then here's an example of my working config. The stuff that is
commented out is what you're looking to implement. However I've set it
up for multiple users with entities. Thought you might like to see
both.

security.config:
    encoders:
        #Symfony\Security\Core\User\AccountInterface:
        MRX\Backend\AuthBundle\Entity\Users:
            algorithm: plaintext

    providers:
        main:
            entity: { class: AuthBundle:Users, property: email }
            #users:
                #foo: { password: foo, roles: ['ROLE_USER',
'ROLE_ADMIN'] }

    firewalls:
        main:
            pattern:    .*
            form_login: true
            anonymous:  true
            logout:     { path: /logout, target: /login }

    access_control:
        - { path: /login.*, role: IS_AUTHENTICATED_ANONYMOUSLY }
        - { path: /.*, role: ROLE_USER }


On Feb 9, 11:26 pm, Klaas Naaijkens <klaas.naaijk...@gmail.com> wrote:
> Hi, I am struggling with the security system in symfony2 for about a
> day now.
>
> I have this in my config_dev.yml (running with the latest version of
> symfony2 github)
> ---------
> security.config:
>    providers:
>        main:
>            users:
>                foo: { password: foo }
>
>    firewalls:
>        main:
>            http-basic: true
>
>    access_control:
>        - { path: /.*, role: ROLE_USER }
>
>    encoders:
>        HelloBundle/Entity/User: plaintext
> ----------
> Then I get this error.
>
> No encoder has been configured for account
> "Symfony\Component\Security\Core\User\User".
>
> Stack Trace
> in /home/klaas/code/LPbackend/vendor/symfony/src/Symfony/Component/
> Security/Core/Encoder/EncoderFactory.php
> line 75 »
>            }
>        }
>        throw new \InvalidArgumentException(sprintf('No encoder has
> been configured for account "%s".', get_class($account)));
>    }}
>
> at EncoderFactory->createEncoder(object(User))
> in /home/klaas/code/LPbackend/vendor/symfony/src/Symfony/Component/
> Security/Core/Encoder/EncoderFactory.php
> line 43 »
> at EncoderFactory->getEncoder(object(User))
> in /home/klaas/code/LPbackend/vendor/symfony/src/Symfony/Component/
> Security/Core/Authentication/Provider/DaoAuthenticationProvider.php
> line 65 »
> at DaoAuthenticationProvider->checkAuthentication(object(User),
> object(UsernamePasswordToken))
> in /home/klaas/code/LPbackend/vendor/symfony/src/Symfony/Component/
> Security/Core/Authentication/Provider/UserAuthenticationProvider.php
> line 70 »
> at UserAuthenticationProvider->authenticate(object(UsernamePasswordToken))
>
> in /home/klaas/code/LPbackend/vendor/symfony/src/Symfony/Component/
> Security/Core/Authentication/AuthenticationProviderManager.php
> line 61 »
> at AuthenticationProviderManager->authenticate(object(UsernamePasswordToken))
>
> in /home/klaas/code/LPbackend/vendor/symfony/src/Symfony/Component/
> Security/Http/Firewall/BasicAuthenticationListener.php
> line 97 »
> at BasicAuthenticationListener->handle(object(Event))
> at call_user_func(array(object(BasicAuthenticationListener),
> 'handle'), object(Event))
> in /home/klaas/code/LPbackend/vendor/symfony/src/Symfony/Bundle/
> FrameworkBundle/Debug/EventDispatcher.php
> line 72 »
> at EventDispatcher->notifyUntil(object(Event))
> in /home/klaas/code/LPbackend/vendor/symfony/src/Symfony/Component/
> Security/Http/Firewall.php
> line 88 »
> at Firewall->handle(object(Event))
> at call_user_func(array(object(Firewall), 'handle'), object(Event))
> in /home/klaas/code/LPbackend/vendor/symfony/src/Symfony/Bundle/
> FrameworkBundle/Debug/EventDispatcher.php
> line 72 »
> at EventDispatcher->notifyUntil(object(Event))
> in /home/klaas/code/LPbackend/vendor/symfony/src/Symfony/Component/
> HttpKernel/bootstrap.php
> line 378 »
> at HttpKernel->handleRaw(object(Request), '1')
> in /home/klaas/code/LPbackend/vendor/symfony/src/Symfony/Component/
> HttpKernel/bootstrap.php
> line 361 »
> at HttpKernel->handle(object(Request), '1', true)
> in /home/klaas/code/LPbackend/vendor/symfony/src/Symfony/Bundle/
> FrameworkBundle/HttpKernel.php
> line 39 »
> at HttpKernel->handle(object(Request), '1', true)
> in /home/klaas/code/LPbackend/vendor/symfony/src/Symfony/Component/
> HttpKernel/bootstrap.php
> line 534 »
> at Kernel->handle(object(Request))
> in /home/klaas/code/LPbackend/web/app_dev.php line 15 »
>
> Any ideas?

-- 
If you want to report a vulnerability issue on symfony, please send it to 
security at symfony-project.com

You received this message because you are subscribed to the Google
Groups "symfony users" group.
To post to this group, send email to symfony-users@googlegroups.com
To unsubscribe from this group, send email to
symfony-users+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/symfony-users?hl=en

Reply via email to