2015-03-27 2 views
0

Я удалил провайдера в памяти и DemoBundle и добавил поставщика базы данных в соответствии с учебным пособием. Но я получаю InvalidArgumentException: «Вы должны хотя бы добавить одного поставщика проверки подлинности».security.yml вызывает InvalidArgumentException: «Вы должны хотя бы добавить одного поставщика проверки подлинности»

Мой security.yml:

# you can read more about security in the related section of the documentation 
# http://symfony.com/doc/current/book/security.html 
security: 
    # http://symfony.com/doc/current/book/security.html#encoding-the-user-s-password 
    encoders: 
    AppBundle\Entity\User: 
     algorithm: bcrypt 

    # http://symfony.com/doc/current/book/security.html#hierarchical-roles 
    role_hierarchy: 
    ROLE_GLOBAL_MODERATOR: ROLE_USER 
    ROLE_ADMIN: ROLE_GLOBAL_MODERATOR 

    # http://symfony.com/doc/current/book/security.html#where-do-users-come-from-user-providers 
    providers: 
    db: 
     entity: 
     class: AppBundle:User 
     property: email 
     # if you're using multiple entity managers 
     # manager_name: customer 

    # the main part of the security, where you can set up firewalls 
    # for specific sections of your app 
    firewalls: 
    # disables authentication for assets and the profiler, adapt it according to your needs 
    dev: 
     pattern: ^/(_(profiler|wdt)|css|images|js)/ 
     security: false 
    default: 
     pattern: ^/ 
     security: false 

    # with these settings you can restrict or allow access for different parts 
    # of your application based on roles, ip, host or methods 
    # http://symfony.com/doc/current/cookbook/security/access_control.html 
    access_control: 
     #- { path: ^/login, roles: IS_AUTHENTICATED_ANONYMOUSLY, requires_channel: https } 

Я также попытался с помощью YAML визуализатор, чтобы убедиться, что я не завинчивать отступы, и это правильно.

+0

Не должно быть 'class: Ns \ AppBundle \ Entity \ User', а не' class: AppBundle: User'? – D4V1D

+0

@ D4V1D Заменен, безрезультатно. – Cysioland

ответ

9

Это связано с тем, что еще не настроен поставщик аутентификации. Я имею в виду под брандмауэром ключом. Поставщики аутентификации являются анонимными, form_login, http_basic и т. Д. Не важно, какой шаблон настроен поставщиком, но по крайней мере один из них должен быть настроен.

firewalls: 
    # disables authentication for assets and the profiler, adapt it according to your needs 
    dev: 
     pattern: ^/(_(profiler|wdt)|css|images|js)/ 
     security: false 
    default: 
     pattern: ^/ 
     anonymous: ~ 
+0

Спасибо тонну. Это действительно заставило меня снять волосы. – Cysioland