1

Its really bothering me a lot. Where did I make mistake or How can I solve this error.

I got an error as InvalidTypeException in ArrayNode.php line 267: -- Invalid type for path "security.providers.in_memory.memory.users.admin:{ password". Expected array, but got string

I am implementing the controller from symfony cookbook. Here is my security.yml

security:
encoders:
    Symfony\Component\Security\Core\User\User: plaintext
    Leo\CLUBBundle\Entity\User: bcrypt
role_hierarchy:
    ROLE_ADMIN: [ROLE_USER]
providers:
    chain_provider:
        chain:
            providers: [in_memory, user_db]
    in_memory:
        memory:
            users:
                admin:{ password: adminpass, roles:ROLE_ADMIN}
    user_db:
        entity:{ class: LeoCLUBBundle:User, property:username }
firewalls:
    main:
        pattern: /.*
        form_login:
            login_path: /login_path
            check_path: /login_check
            default_target_path: /
        logout:
            path: /logout
            target: /
        security: true
        anonymous: true
access_control:
    - { path: /login, roles: IS_AUTHENTICATED_ANONYMOUSLY }
    - { path: /user, roles: ROLE_ADMIN }
    - { path: /.*, roles: IS_AUTHENTICATED_ANONYMOUSLY }

2 Answers 2

4

Spaces and intentions are very important in Yaml, so change

admin:{ password: adminpass, roles:ROLE_ADMIN}

to

admin: { password: adminpass, roles: [ 'ROLE_ADMIN' ] }

Also change

entity:{ class: LeoCLUBBundle:User, property:username }

to

entity: { class: LeoCLUBBundle:User, property: username }
Sign up to request clarification or add additional context in comments.

2 Comments

Using this will then trigger another error Unrecognized options "entity:{ class" under "security.providers.user_db"
I haven't realized that a single space will give me such a big trouble. Thanks a lot. Learnt my lesson.
0

I had the same problem after manual modification of composer.json and composer.lock files.

After that modifications, trying to install mailer with "composer require symfony/mailer", I had many errors under "Your requirements could not be resolved to an installable set of packages.":

Problem 1 - Root composer.json requires symfony/asset 6.0.*, found symfony/asset[v6.0.0, v6.0.1] but the package is fixed to v4.4.27 (lock file version) by a partial update and that version does not match. Make sure you list it as an argument for the update command.

Problem 2 - Root composer.json requires symfony/console 6.0.*, found symfony/console[v6.0.0, v6.0.1, v6.0.2] but the package is fixed to v4.4.36 (lock file version) by a partial update and that version does not match. Make sure you list it as an argument for the update command.

Problem 3 .....and so on"

To fix this problems I had to futher modify composer.json and composer.lock, until the "composer update "symfony/*" -W" worked fine, except for the message "Unrecognized option "anonymous" under "security.firewalls.main".

I found out that the security.yaml file got changed: instead of "lazy: true" there was "anonymous: lazy".

Reverting to "lazy: true", no more error messages.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.