我尝试
时出现此问题php app / console server:运行
它告诉我这个错误:
无法识别的选项" admin"在" security.providers.in_memory.memory"
这是我的 security.yml
security:
encoders:
Symfony\Component\Security\Core\User\User: plaintext
Custom\CMSBundle\Entity\User: bcrypt
role_hierarchy:
ROLE_ADMIN: [ROLE_USER]
providers:
chain_providers:
chain:
providers: [in_memory, user_db]
in_memory:
memory:
users:
admin: { password: adminpass, roles: ROLE_ADMIN }
user_db:
entity: { class: CustomCMSBundle:User, property: username }
firewalls:
main:
pattern: /.*
form_login:
login_path: /login
check_path: /login_check
default_target_path: /
logout:
path: /logout
target: /
security: true
anonymous: true
access_control:
- { path: /login, roles: IS_AUTHENTICATED_ANONYMOUSLY }
- { path: /cms/user, roles: ROLE_ADMIN }
- { path: /.*, roles: IS_AUTHENTICATED_ANONYMOUSLY }
答案 0 :(得分:1)
定义的用户(在这种情况下为admin
)应该在users
地图内定义,因此必须缩进超过users
:
in_memory:
memory:
users:
admin: { password: adminpass, roles: ROLE_ADMIN }