php - 配置用户和角色时 Symfony php 错误
问题描述
我正在尝试在我的 php 程序中配置一组用户和角色。我已按照 synfony 网站上的教程进行操作,但收到以下错误:
(1/1) InvalidTypeException 路径“security.access_control.0.path”的类型无效。预期的标量,但得到了数组。提示:使用 urldecoded 格式
安全.yml:
# To get started with security, check out the documentation:
# https://symfony.com/doc/current/security.html
security:
providers:
in_memory:
memory:
users:
inkoper:
password: inkoper
roles: 'ROLE_INKOPER'
access_control:
- { path '^/*', roles: [ROLE_INKOPER] }
encoders:
Symfony\Component\Security\Core\User\User: plaintext
firewalls:
# disables authentication for assets and the profiler, adapt it according to your needs
dev:
pattern: ^/(_(profiler|wdt)|css|images|js)/
security: false
main:
anonymous: ~
# activate different ways to authenticate
# https://symfony.com/doc/current/security.html#a-configuring-how-your-users-will-authenticate
http_basic: ~
# https://symfony.com/doc/current/security/form_login_setup.html
#form_login: ~
更新
感谢 Andrew Vakhniuk,我发现了这个问题。我忘了在访问控制下的路径后加上一个':'。
解决方案
将您的访问控制更改为
- { path: '^/', roles: ROLE_INKOPER }
推荐阅读
- android - Firebase 单值事件监听器每次都返回 null
- javascript - 社区版中的 ag-grid 客户端行模型 - 不像官方文档那样表现
- apache-spark - Spark读取具有多种记录类型的文件
- java - 这个实例变量是否“隐藏”?
- python-3.x - discord.py 错误 - ClientConnectorCertificateError
- laravel-backpack - 如何在 Backpack 中查看列表视图后面的 AJAX 查询?
- testing - 使用记者时,Testcafe 进程无法结束
- grep - 我怎样才能只列出目录名称,没有尾随“/”?
- javascript - 为什么 Javascript 会这样?
- python - 对象提取与构造