简体   繁体   English

安全和登录 - symfony3

[英]Security and login - symfony3

i have an application based on symfony3.我有一个基于 symfony3 的应用程序。 I did register and login from doccumentation.我确实从文档中注册和登录。 It's my code in security.yml这是我在 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

And on localhost is - FileLoaderLoadException in FileLoader.php line 118: The file "C:\\xampp\\htdocs\\game\\app/config\\security.yml" does not contain valid YAML in C:\\xampp\\htdocs\\game\\app/config\\security.yml (which is being imported from "C:\\xampp\\htdocs\\game\\app/config\\config.yml").在本地主机上是 - 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”导入)。

Can you tell me what i'm doing wrong?你能告诉我我做错了什么吗? Another code is from my app is here - https://github.com/xrbartek/mirko另一个代码来自我的应用程序在这里 - https://github.com/xrbartek/mirko

YAML is very particular on how indentation will change the structure of the configuration. YAML 非常注重缩进将如何改变配置的结构。 You must keep the number of spaces consistent throughout the entire file.您必须在整个文件中保持空格数一致。

I've taken a look at your config and could see that by running it through a YAML parser there were some issues.我查看了您的配置,可以看到通过YAML 解析器运行它存在一些问题。

I've corrected this to valid YAML below:我已将此更正为以下有效的 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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM