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 多电路系统共用电源的串扰问题
  • ¥15 shape_predictor_68_face_landmarks.dat
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 对于相关问题的求解与代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料