Fab*_*ius 2 yaml symfony fosuserbundle
在Symfony中设置FOSUserBundle时,我遇到了一个奇怪的错误.我收到此错误消息:
A colon cannot be used in an unquoted mapping value at line 30 (near " csrf_token_generator: security.csrf.token_manager").
Run Code Online (Sandbox Code Playgroud)
这是我的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 }
Run Code Online (Sandbox Code Playgroud)
我已经尝试评论错误消息(csrf_token_generator)中提到的行,但错误仍然存在,现在指向它上面的行.
Ale*_*eri 11
我认为这是一个缩进的问题,
试着改变这个:
pattern: ^/
form_login:
provider: fos_userbundle
csrf_token_generator: security.csrf.token_manager
logout: true
anonymous: true
Run Code Online (Sandbox Code Playgroud)
对此:
pattern: ^/
form_login:
provider: fos_userbundle
csrf_token_generator: security.csrf.token_manager
logout: true
anonymous: true
Run Code Online (Sandbox Code Playgroud)