我要去gcrazy!
我刚刚将FOSUserBundle集成到我的Symfony2项目中,现在我在登录界面上收到错误。
在呈现模板期间抛出异常(“安全上下文不包含身份验证令牌。一个可能的原因可能是此URL没有配置防火墙。”)在FOSUserBundle :: layout.html.twig中在第8行。
My Security.yml
security:
encoders:
Symfony\Component\Security\Core\User\User: plaintext
FOS\UserBundle\Model\UserInterface: sha512
role_hierarchy:
ROLE_ADMIN: ROLE_USER
ROLE_SUPER_ADMIN: [ROLE_USER, ROLE_ADMIN, ROLE_ALLOWED_TO_SWITCH]
providers:
fos_userbundle:
id: fos_user.user_provider.username
#entity: {class Smada\Agenda7Bundle\Entity\User, property: username}
firewalls:
dev:
pattern: ^/(_(profiler|wdt)|css|images|js)/
security: false
login:
pattern: ^/login$
security: false
main:
pattern: ^/
form_login:
provider: fos_userbundle
csrf_provider: form.csrf_provider
logout: true
anonymous: false
# secured_area:
# pattern: ^/demo/secured/
# form_login:
# check_path: _security_check
# login_path: _demo_login
# logout:
# path: _demo_logout
# target: _demo
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 }
我的config.yml里面有这个
fos_user:
db_driver: propel # other valid values are 'mongodb', 'couchdb' and 'propel'
firewall_name: main
user_class: Smada\Agenda7\Entity\User
有谁知道我的问题是什么? 提前谢谢!
答案 0 :(得分:0)
IMO你有2个/ login url规则
请删除:
firewalls:
# ...
login:
pattern: ^/login$
security: false