1

チュートリアルに従って、メモリ内プロバイダーと DemoBundle を削除し、データベース プロバイダーを追加しました。しかし、「少なくとも1つの認証プロバイダーを追加する必要があります」というメッセージが表示され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 ビジュアライザーを使用してみましたが、正しいです。

4

1 に答える 1

9

これは、認証プロバイダーをまだ構成していないためです。ファイアウォールキーの下を意味します。認証プロバイダーは、anonymous、form_login、http_basic などです。どのパターンのプロバイダーが構成されているかは重要ではありませんが、少なくとも 1 つが構成されている必要があります。

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: ~
于 2015-03-27T21:04:18.110 に答える