简体   繁体   中英

Symfony php error when configuring users and roles

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.

将访问控制更改为

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM