2
votes

I'm currently having some frustration trying to implement the Symfony2 cookbook for creating a custom user provider utilising doctrine: http://symfony.com/doc/2.0/cookbook/security/entity_provider.html

Here is my security.yml file:

security:
    encoders:
        Rep\Bundle\ProjectBundle\Model\User:
            algorithm:        sha1
            encode_as_base64: false
            iterations:       1

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

    providers:
        user_db:
            entity: { class: ProjectBundle:User, property: username }

    firewalls:
        admin_area:
            pattern:    ^/admin
            http_basic: ~

    access_control:
        - { path: ^/admin, roles: ROLE_ADMIN }

Here is my error:

Obvious questions:

  1. Do I have doctrine installed? Yes. And Registered in the kernel.
  2. Have I created the user interface and provider. Yes.

Also, I am choosing to build this instead of using the FOSUserBundle as it's too "bulky" for what I need, so any help would be ideal!

1
Hello, another obvious question... Do you have DoctrineBundle installed ? AFAIK doctrine.orm.security.user.provider is abstract service defined in DoctrineBundle... - l3l0
This was a stupid error on my part - the bundle was registered in the kernel, but the configuration for it was missing. The error doesn't point directly to such a problem, but process of elimination did. Problem resolved! - Dan Belden

1 Answers

2
votes

Problem was caused by missing configuration information for doctrine, however the bundle was registered in the kernel. Strange error message which doesn't point towards lacking config, but process of elimination resolved my issue.