Symfony的4.2:防火墙配置不加载存储器中的用户提供

问题描述 投票:0回答:1

对于我test环境,我已经配置基于内存的用户提供:

config/packages/test/security.yaml

security:
  providers:
    unit_testing:
      memory:
        users:
          test1: { password: $testpwd1, roles: ['ROLE_SUPER_ADMIN'] }
          test2: { password: $testpwd2, roles: ['ROLE_SPECIAL1_ADMIN'] }
          test3: { password: $testpwd3, roles: ['ROLE_SPECIAL2_ADMIN'] }
  firewalls:
    admin:
      form_login:
        provider: unit_testing

我尝试测试登录表单中的功能测试。

tests/Controller/LoginControllerTest.php

$client = static::createClient();
$crawler = $client->request(Request::METHOD_GET, '/login');
$form = $crawler->selectButton('Login')->form(['_username' => 'test1', '_password' => '$testPwd1']);
$client->submit($form);

登录失败。调试登录过程显示,尽管Kernel.php加载从test额外的安全配置方面,FirewallListener取其中有provider = null的配置。

在标准环境,生产数据登录成功。

到底是怎么回事?

如果需要,我会提供额外的代码。

authentication phpunit firewall configuration-files symfony4
1个回答
0
投票

我进一步孤立的问题,并来到了伤心的认识到我的问题实际上不是用户提供。

用于存储器提供商配置的密码有一个旧编码,并且因此较新的编码算法产生的哈希和不匹配。一个原因可能是迁移从3.4到4.2,因为有许多更改配置。

手动编码目标密码通过php bin/console security:encode-password <arg>解决了这个问题对我来说。

© www.soinside.com 2019 - 2024. All rights reserved.