Symfony4 - Basic Auth looping while using DB provider

时光毁灭记忆、已成空白 提交于 2019-12-24 09:49:48

问题


I'm desperate : I'm using Symfony for years, and today I'm stuck on a basic stuff. As FOSUserBundle is not implemented for Sf4 yet, I decided to create a really basic User entity in DB to load user.

But when I enter my username/password in the BasicAuth windows in my web browser (chrome) it's not logging me and loops over and over.

Here is my security file :

security:
    encoders:
        App\Entity\User:
            algorithm: bcrypt

    providers:
        native_provider:
            entity:
                class: App\Entity\User
                property: username
                manager_name: native_users

    firewalls:
        main:
            pattern:    ^/
            http_basic: ~
            provider: native_provider

    access_control:
        - { path: ^/, roles: ROLE_USER }

    role_hierarchy:
        ROLE_ADMIN: ROLE_USER

And my User class is exactly the same as the one in the symfony example : https://symfony.com/doc/current/security/entity_provider.html#create-your-user-entity

Finally I created some User fixtures using [nelmio/alice][1] :

App\Entity\User:
    user_1:
        id: '<uuid()>'
        username: 'admin'
        password: '\$2y\$10\$574w3EitCqOaHmhu4ER49.KPG2EMtcQlYrO0vdPyYW/EuqTHMCB0C'
        email: 'admin@test.com'
        isActive: true

Where '\$2y\$10\$574w3EitCqOaHmhu4ER49.KPG2EMtcQlYrO0vdPyYW/EuqTHMCB0C' reprensent the "admin" word coded in bcrypt.

Despite all these things, basic auth won't work. Any Idea ?

Thanks !

来源:https://stackoverflow.com/questions/48483993/symfony4-basic-auth-looping-while-using-db-provider

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!