Symfony2 chain_provider in_memory users log in with bad credentials

I want to have one hard-coded user and the rest of the users coming from the database. When I log in with db users, it works, but if I log in with a hard-coded user, it shows the "Bad credentials" error. Here is part of my security.yml file:

security:
    encoders:
        Valoran\DrushBundle\Entity\User:
            algorithm: bcrypt
            cost:      15

role_hierarchy:
    ROLE_ADMIN:       ROLE_USER
    ROLE_SUPER_ADMIN: [ROLE_USER, ROLE_ADMIN, ROLE_ALLOWED_TO_SWITCH]

providers:
    chain_provider:
        chain:
            providers: [in_memory, user_db]
    in_memory:
        memory:
            users:
                foo: { password: test }
    user_db:
        entity: { class: Acme\DrushBundle\Entity\User, property: userName }
+4
source share
1 answer

I ran into the same problem, I am adding an answer to make it more visible to others. If you get

No encoder for Symfony Chain Provider \ Component \ Security \ Core \ User \ User account

, ( ) [security.yml]

security:
    encoders:
        Splendonia\Bundle\UserBundle\Entity\User:
            algorithm: sha512
            encode-as-base64: true
            iterations: 10
        Symfony\Component\Security\Core\User\User: plaintext

. , :

providers:
        chain_provider:
            chain:
                providers: [in_memory, main]
        in_memory:
            memory:
                users:
                    guest:  { password: guest, roles: [ 'ROLE_GUEST' ] }
        main:
            entity: { class: Splendonia\Bundle\UserBundle\Entity\User, property: email }

chain_provider , :

firewalls:
        dev:
            pattern:  ^/(_(profiler|wdt)|css|images|js)/
            security: false

        login:
            pattern:  ^/demo/secured/login$
            security: false

        secured_area:
            pattern:    ^/
            anonymous: ~
            provider: chain_provider
            form_login:
                login_path: login
                check_path: login_check
                default_target_path: /dashboard

            logout:
                path:   /logout
                target: /

.

+4

Source: https://habr.com/ru/post/1525487/


All Articles