security.yml 导致 InvalidArgumentException:"You must at least add one authentication provider"
security.yml causes InvalidArgumentException: "You must at least add one authentication provider"
我按照教程删除了内存中提供程序和 DemoBundle,并添加了数据库提供程序。但是我得到 InvalidArgumentException
:"You must at least add one authentication provider"。
我的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 可视化工具,以确保我没有搞砸缩进,而且它是正确的。
这是因为您还没有配置身份验证提供程序。我的意思是在防火墙键下。身份验证提供程序是匿名的,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: ~
我按照教程删除了内存中提供程序和 DemoBundle,并添加了数据库提供程序。但是我得到 InvalidArgumentException
:"You must at least add one authentication provider"。
我的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 可视化工具,以确保我没有搞砸缩进,而且它是正确的。
这是因为您还没有配置身份验证提供程序。我的意思是在防火墙键下。身份验证提供程序是匿名的,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: ~