Symfony2 plaintext users don't work

2019-07-16 11:25发布

问题:

I tried to configure a simple secured admin area by configuring it into secury.yml. I used the example of Symfony :

    security:
        firewalls:
            secured_area:
                pattern:    ^/
                anonymous: ~
                http_basic:
                    realm: "Secured Admin Area"

        access_control:
            - { path: ^/admin, roles: ROLE_ADMIN }

        providers:
            in_memory:
                users:
                    ryan:  { password: ryanpass, roles: 'ROLE_USER' }
                    admin: { password: kitten, roles: 'ROLE_ADMIN' }

        encoders:
            Symfony\Component\Security\Core\User\User: plaintext

I have the username / password prompt, but the couples ryan:ryanpass and admin:kitten doesn't work. Is there something wrong ?

Thank you

回答1:

I think you need to add the provider name to the http_basic section in your case:

http_basic:
    realm: "Secured Admin Area"
    provider: in_memory