Skip to content

Commit a1a5eea

Browse files
Merge branch '5.4' into 6.3
* 5.4: [Messenger] Fix cloned TraceableStack not unstacking the stack independently [DependencyInjection] Fix autocasting null env values to empty string with container.env_var_processors_locator [Cache] Fix support for Redis Sentinel using php-redis 6.0.0 minor #51693 Disable the dead code analysis in Psalm (stof) Update the PR template [SecurityBundle][PasswordHasher] Fix password migration with custom hasher service with security bundle config [Translator] Fix support for `default_path` in XML [HttpClient] Fix TraceableResponse if response has no destruct method
2 parents 93b1bef + 8f432fa commit a1a5eea

File tree

2 files changed

+31
-1
lines changed

2 files changed

+31
-1
lines changed

DependencyInjection/SecurityExtension.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -721,7 +721,10 @@ private function createHasher(array $config): Reference|array
721721
{
722722
// a custom hasher service
723723
if (isset($config['id'])) {
724-
return new Reference($config['id']);
724+
return $config['migrate_from'] ?? false ? [
725+
'instance' => new Reference($config['id']),
726+
'migrate_from' => $config['migrate_from'],
727+
] : new Reference($config['id']);
725728
}
726729

727730
if ($config['migrate_from'] ?? false) {

Tests/DependencyInjection/SecurityExtensionTest.php

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -887,6 +887,33 @@ public function testNothingDoneWithEmptyConfiguration()
887887
$this->assertFalse($container->has('security.authorization_checker'));
888888
}
889889

890+
public function testCustomHasherWithMigrateFrom()
891+
{
892+
$container = $this->getRawContainer();
893+
894+
$container->loadFromExtension('security', [
895+
'enable_authenticator_manager' => true,
896+
'password_hashers' => [
897+
'legacy' => 'md5',
898+
'App\User' => [
899+
'id' => 'App\Security\CustomHasher',
900+
'migrate_from' => 'legacy',
901+
],
902+
],
903+
'firewalls' => ['main' => ['http_basic' => true]],
904+
]);
905+
906+
$container->compile();
907+
908+
$hashersMap = $container->getDefinition('security.password_hasher_factory')->getArgument(0);
909+
910+
$this->assertArrayHasKey('App\User', $hashersMap);
911+
$this->assertEquals($hashersMap['App\User'], [
912+
'instance' => new Reference('App\Security\CustomHasher'),
913+
'migrate_from' => ['legacy'],
914+
]);
915+
}
916+
890917
protected function getRawContainer()
891918
{
892919
$container = new ContainerBuilder();

0 commit comments

Comments
 (0)