【问题标题】:Symfony php error when configuring users and roles配置用户和角色时 Symfony php 错误
【发布时间】:2018-05-11 15:27:49
【问题描述】:

我正在尝试在我的 php 程序中配置一组用户和角色。我已按照 synfony 网站上的教程进行操作,但收到以下错误:

(1/1) 无效类型异常 路径“security.access_control.0.path”的类型无效。预期的标量,但得到了数组。 提示:使用 urldecoded 格式

Security.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,我找到了问题所在。我忘了在访问控制下的路径后面加上一个 ':'。

【问题讨论】:

    标签: php symfony security


    【解决方案1】:

    将您的访问控制更改为

       - { path: '^/', roles: ROLE_INKOPER }
    

    【讨论】:

    • 感谢您的回复,我已经尝试过您的建议,但仍然收到错误消息。
    • 对不起,我忘记在路径后添加分号':',再试一次
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2023-02-25
    • 1970-01-01
    • 2018-10-16
    • 2016-10-26
    • 1970-01-01
    • 2018-04-16
    • 1970-01-01
    相关资源
    最近更新 更多