security.yml导致InvalidArgumentException:“您必须至少添加一个身份验证提供程序" [英] security.yml causes InvalidArgumentException: "You must at least add one authentication provider"

查看:133
本文介绍了security.yml导致InvalidArgumentException:“您必须至少添加一个身份验证提供程序"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

按照教程,我删除了内存提供程序和DemoBundle,并添加了数据库提供程序.但是我得到了InvalidArgumentException:您必须至少添加一个身份验证提供程序" .

I removed in-memory provider and DemoBundle, and added database provider, as per tutorial. But I'm getting InvalidArgumentException: "You must at least add one authentication provider".

我的security.yml:

My 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可视化程序,以确保我没有弄紧缩进,这是正确的.

I also tried using a YAML visualizer, to make sure, that I didn't screw up indentation, and it's correct.

推荐答案

这是因为您尚未配置身份验证提供程序.我的意思是在防火墙密钥下.身份验证提供程序是匿名的,form_login,http_basic等.对于提供程序配置哪种模式并不重要,但是必须配置其中至少一个.

This is because you don't have configured authentication provider yet. I mean under firewalls key. Authentication providers are anonymous, form_login, http_basic etc. It is not important for what pattern is provider configured but at least one of them must be configured.

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: ~

这篇关于security.yml导致InvalidArgumentException:“您必须至少添加一个身份验证提供程序"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆