更新security.yaml文件的用户密码

时间:2018-10-15 21:34:03

标签: symfony4

我将 config / packages / security.yaml 文件配置为in the documentation,其中包含硬编码用户,如您所见:

security:
    # https://symfony.com/doc/current/security.html#where-do-users-come-from-user-providers
    providers:
        in_memory:
            memory:
                users:
                    ryan:
                        password: ryanpass
                        roles: 'ROLE_USER'
                    admin:
                        password: kitten
                        roles: 'ROLE_ADMIN'
    encoders:
        Symfony\Component\Security\Core\User\User:
            algorithm: bcrypt
            cost: 12
    firewalls:
        dev:
            pattern: ^/(_(profiler|wdt)|css|images|js)/
            security: false
        main:
            anonymous: ~
            http_basic: ~
    access_control:
        # require ROLE_ADMIN for /admin*
        - { path: ^/admin, roles: ROLE_ADMIN }

我启动了symfony命令: php bin/console security:encode-password,以便使用bcrypt算法对密码进行编码。通过这种方式,通常我会在 config / packages / security.yaml 文件中看到更改,例如:

users:
    ryan:
        password: $2a$12$LCY0MefVIEc3TYPHV9SNnuzOfyr2p/AXIGoQJEDs4am4JwhNz/jli
        roles: 'ROLE_USER'
    admin:
        password: $2a$12$cyTWeE9kpq1PjqKFiWUZFuCRPwVyAZwm4XzMZ1qPUFl7/flCM3V0G
        roles: 'ROLE_ADMIN'

但是启动此命令后,控制台要求我输入密码:

Symfony Password Encoder Utility
================================

 Type in your password to be encoded:
 > 

您能解释一下如何获得正确的行为吗?

预先感谢

0 个答案:

没有答案