2015-07-10 30 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 }