首页 文章

安全和登录 - symfony3

提问于
浏览
-2

我有一个基于symfony3的应用程序 . 我确实注册并从doccumentation登录 . 这是我在security.yml中的代码

security:
encoders:
       AppBundle\Entity\User: bcrypt

providers:
    our_db_provider:
      entity:
          class: AppBundle:User
          property: username

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

     main:
        pattern:    ^/
        http_basic: ~
        provider: our_db_provider
          form_login:
                  login_path: login
                  check_path: login

在localhost上 - FileLoader.php第118行中的FileLoaderLoadException:文件“C:\ xampp \ htdocs \ game \ app / config \ security.yml”在C:\ xampp \ htdocs \ game \ app /中不包含有效的YAML config \ security.yml(从“C:\ xampp \ htdocs \ game \ app / config \ config.yml”导入) .

你能告诉我我做错了什么吗?另一个代码来自我的应用程序在这里 - https://github.com/xrbartek/mirko

1 回答

  • 3

    YAML非常特别关于缩进将如何改变配置的结构 . 您必须在整个文件中保持一致的空格数 .

    我已经看了your config,可以看到通过YAML parser运行它有一些问题 .

    我已将此更正为以下有效的YAML:

    # To get started with security, check out the documentation:
    # http://symfony.com/doc/current/book/security.html
    security:
        encoders:
            AppBundle\Entity\User: bcrypt
    
        # http://symfony.com/doc/current/book/security.html#where-do-users-come-from-user-providers
        providers:
            our_db_provider:
                entity:
                    class: AppBundle:User
                    property: username
    
        firewalls:
            # disables authentication for assets and the profiler, adapt it according to your needs
            dev:
                pattern: ^/(_(profiler|wdt)|css|images|js)/
                security: false
    
            main:
                pattern:    ^/
                http_basic: ~
                provider: our_db_provider
                form_login:
                    login_path: login
                    check_path: login
    
                # activate different ways to authenticate
    
                # http_basic: ~
                # http://symfony.com/doc/current/book/security.html#a-configuring-how-your-users-will-authenticate
    
                # form_login: ~
                # http://symfony.com/doc/current/cookbook/security/form_login_setup.html
                # app/config/security.yml
    

相关问题