【发布时间】:2017-12-01 12:56:03
【问题描述】:
我在 Symfony 中设置 FOSUserBundle 时遇到了一个奇怪的错误。 我收到此错误消息:
A colon cannot be used in an unquoted mapping value at line 30 (near " csrf_token_generator: security.csrf.token_manager").
这是我的security.yml,谁能告诉我我做错了什么?
# 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
# https://symfony.com/doc/current/security.html#b-configuring-how-users-are-loaded
providers:
# in_memory:
# memory: ~
fos_userbundle:
id: fos_user.user_provider.username
firewalls:
main:
pattern: ^/
form_login:
provider: fos_userbundle
csrf_token_generator: security.csrf.token_manager
logout: true
anonymous: true
# disables authentication for assets and the profiler, adapt it according to your needs
dev:
pattern: ^/(_(profiler|wdt)|css|images|js)/
security: false
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 }
我已尝试注释掉错误消息 (csrf_token_generator) 中提到的行,但错误仍然存在,现在指向它上面的行。
【问题讨论】:
-
尝试引用值 "security.csrf.token_manager" => csrf_token_generator: "security.csrf.token_manager"
-
我试过了,没区别。
标签: symfony yaml fosuserbundle