douluolan9101 2018-05-11 15:27
浏览 68
已采纳

配置用户和角色时出现Symfony php错误

I am trying to configure a set of users and roles in my php program. I've followed the tutorial on the synfony website but I recieve the following error:

(1/1) InvalidTypeException Invalid type for path "security.access_control.0.path". Expected scalar, but got array. Hint: use the urldecoded format

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: ~

Update

I found the problem thanks to Andrew Vakhniuk. I forgot to put a ':' after path under access control.

  • 写回答

1条回答

  • douyinmian8151 2018-05-11 15:33
    关注

    Change your access control to

       - { path: '^/', roles: ROLE_INKOPER }
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 树莓派与pix飞控通信
  • ¥15 自动转发微信群信息到另外一个微信群
  • ¥15 outlook无法配置成功
  • ¥30 这是哪个作者做的宝宝起名网站
  • ¥60 版本过低apk如何修改可以兼容新的安卓系统
  • ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏
  • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
  • ¥50 有数据,怎么用matlab求全要素生产率
  • ¥15 TI的insta-spin例程
  • ¥15 完成下列问题完成下列问题