2017-09-11 21 views
0

你好,我有與fosuserbundleERRO-您必須配置支票路徑通過在您的安全防火牆配置使用form_login防火牆處理

symfony項目的一個問題,當我做登錄我給這個錯誤

You must configure the check path to be handled by the firewall using form_login in your security firewall configuration.

我嘗試不同的代碼,總是得到一些錯誤

我使用:

的symfony 3 FOSUserBundle 2.0

config.yml

fos_user: 
    db_driver: orm # other valid values are 'mongodb' and 'couchdb' 
    firewall_name: main 
    user_class: AppBundle\Entity\User 
    from_email: 
     address: "[email protected]" 
     sender_name: "Test App" 

路由

app: 
 
    resource: '@AppBundle/Controller/' 
 
    type: annotation 
 

 
admin_area: 
 
    resource: "@SonataAdminBundle/Resources/config/routing/sonata_admin.xml" 
 
    prefix: /admin 
 

 
fos_user: 
 
    resource: "@FOSUserBundle/Resources/config/routing/all.xml"

安全

# To get started with security, check out the documentation: 
 
# https://symfony.com/doc/current/security.html 
 
security: 
 

 
    # https://symfony.com/doc/current/security.html#b-configuring-how-users-are-loaded 
 
    providers: 
 
     in_memory: 
 
      memory: ~ 
 

 

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

 
     main: 
 
      anonymous: ~ 
 
      # activate different ways to authenticate 
 

 
      # https://symfony.com/doc/current/security.html#a-configuring-how-your-users-will-authenticate 
 
      #http_basic: ~ 
 

 
      # https://symfony.com/doc/current/security/form_login_setup.html 
 
      #form_login: ~ 
 

 
    encoders: 
 
     FOS\UserBundle\Model\UserInterface: bcrypt 
 

 
    role_hierarchy: 
 
     ROLE_ADMIN:  ROLE_USER 
 
     ROLE_SUPER_ADMIN: ROLE_ADMIN 
 

 
    providers: 
 
     fos_userbundle: 
 
      id: fos_user.user_provider.username 
 

 
    firewalls: 
 
     main: 
 
      pattern: ^/admin 
 
      form_login: 
 
       login_path: /login 
 
       check_path: /login_check 
 
       provider: fos_userbundle 
 
       csrf_provider: form.csrf_provider 
 
       
 
    access_control: 
 
     - { path: ^/login$, role: IS_AUTHENTICATED_ANONYMOUSLY } 
 
     - { path: ^/register, role: IS_AUTHENTICATED_ANONYMOUSLY } 
 
     - { path: ^/resetting, role: IS_AUTHENTICATED_ANONYMOUSLY } 
 
     - { path: ^/admin/, role: ROLE_ADMIN }

在這個項目中我用的是sonata管理軟件包,能幹嗎?

希望一些幫助THX

回答

0

security.yml有重複的主防火牆,刪除第一併保持第二,因爲它包含form_login是解決問題

# To get started with security, check out the documentation: 
# https://symfony.com/doc/current/security.html 
security:  
    encoders: 
     FOS\UserBundle\Model\UserInterface: bcrypt 

    role_hierarchy: 
     ROLE_ADMIN:  ROLE_USER 
     ROLE_SUPER_ADMIN: ROLE_ADMIN 

    providers: 
     fos_userbundle: 
      id: fos_user.user_provider.username 

    firewalls: 
     dev: 
      pattern: ^/(_(profiler|wdt)|css|images|js)/ 
      security: false 

     main: 
      pattern: ^/admin 
      form_login: 
       login_path: /login 
       check_path: /login_check 
       provider: fos_userbundle 
       csrf_provider: form.csrf_provider 

    access_control: 
     - { path: ^/login$, role: IS_AUTHENTICATED_ANONYMOUSLY } 
     - { path: ^/register, role: IS_AUTHENTICATED_ANONYMOUSLY } 
     - { path: ^/resetting, role: IS_AUTHENTICATED_ANONYMOUSLY } 
     - { path: ^/admin/, role: ROLE_ADMIN } 

doc瞭解更多詳情。

相關問題