2015-07-10 57 views
1

我使用FOSuserbunble,一切工作正常,現在的 app_dev.php /登錄 我有一個「全認證才能訪問該資源。」 500內部服務器錯誤 - InsufficientAuthenticationException 1鏈接的異常:AccessDeniedException異常»Symfony2中,FOS userbundle,全面驗證才能訪問該資源

我security.yml是

# you can read more about security in the related section of the documentation 

http://symfony.com/doc/current/book/security.html

安全: 編碼器: OandP \ UserBundle \實體\用戶:SHA512

# http://symfony.com/doc/current/book/security.html#hierarchical-roles 
role_hierarchy: 
    ROLE_ADMIN:  [ROLE_CONCIERGE] 
    ROLE_SUPER_ADMIN: [ROLE_CONCIERGE, ROLE_USER, ROLE_ADMIN, ROLE_ALLOWED_TO_SWITCH] 

# http://symfony.com/doc/current/book/security.html#where-do-users-come-from-user-providers 
providers: 
    fos_userbundle: 
     id: fos_user.user_provider.username 

# the main part of the security, where you can set up firewalls 
# for specific sections of your app 
firewalls: 
    # … le pare-feu « dev » 
    # Firewall principal pour le reste de notre site 
    dev: 
     pattern: ^/(_(profiler|wdt)|css|images|js|ws)/ 
     security: false 

    main_login: 
     pattern: ^/login$ 
     anonymous: true 
    main_resettingRequest: 
     pattern: /resetting/request$ 
     anonymous: true 
    main_resettingSendEmailt: 
     pattern: /resetting/send-email$ 
     anonymous: true 
    main_resettingCheckEmail: 
     pattern: /resetting/check-email$ 
     anonymous: true 
    main: 
     pattern:  ^/ 
     anonymous:  false 
     provider:  fos_userbundle 
     form_login: 
      login_path: /login 
      check_path: /login_check 
      csrf_provider: form.csrf_provider 
     logout: 
      path:  /logout 
      target: /
      invalidate_session: false 
     remember_me: 
      key:  %secret% 



# 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/book/security.html#security-book-access-control-matching-options 
access_control: 
    #- { path: ^/members/hello, roles: IS_AUTHENTICATED_ANONYMOUSLY } 

如果有人有一個想法 非常感謝你的幫助

+0

中目前的Symfony拋出一個500錯誤,它應該返回一個錯誤一個401,這是你在這裏看到的錯誤。它已經開放了很長一段時間。 https://github.com/symfony/symfony/issues/8467 – StampyCode

回答

0

您還沒有建立自己的網站涉及access_controls:

access_control: 
    - { path: ^/login$, role: IS_AUTHENTICATED_ANONYMOUSLY } 
    - { path: ^/register, role: IS_AUTHENTICATED_ANONYMOUSLY } 
    - { path: ^/resetting, role: IS_AUTHENTICATED_ANONYMOUSLY } 
    - { path: ^/profile, role: ROLE_USER }