Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitdca28a2

Browse files
committed
[PasswordHasher] Prevent PHP fatal error when using auto algorithm
1 parent10607db commitdca28a2

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

‎src/Symfony/Component/PasswordHasher/Hasher/PasswordHasherFactory.php‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,9 +116,13 @@ private function getHasherConfigFromAlgorithm(array $config): array
116116
if ('auto' ===$config['algorithm']) {
117117
// "plaintext" is not listed as any leaked hashes could then be used to authenticate directly
118118
if (SodiumPasswordHasher::isSupported()) {
119-
$algorithms = ['native','sodium','pbkdf2',$config['hash_algorithm']];
119+
$algorithms = ['native','sodium','pbkdf2'];
120120
}else {
121-
$algorithms = ['native','pbkdf2',$config['hash_algorithm']];
121+
$algorithms = ['native','pbkdf2'];
122+
}
123+
124+
if ($config['hash_algorithm'] ??'') {
125+
$algorithms[] =$config['hash_algorithm'];
122126
}
123127

124128
$hasherChain = [];

‎src/Symfony/Component/PasswordHasher/Tests/Hasher/PasswordHasherFactoryTest.php‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
useSymfony\Component\PasswordHasher\Hasher\PasswordHasherAwareInterface;
1919
useSymfony\Component\PasswordHasher\Hasher\PasswordHasherFactory;
2020
useSymfony\Component\PasswordHasher\Hasher\SodiumPasswordHasher;
21+
useSymfony\Component\PasswordHasher\PasswordHasherInterface;
2122
useSymfony\Component\Security\Core\Encoder\PlaintextPasswordEncoder;
2223
useSymfony\Component\Security\Core\User\InMemoryUser;
2324
useSymfony\Component\Security\Core\User\UserInterface;
@@ -85,6 +86,16 @@ public function testGetHasherConfiguredForConcreteClassWithClassName()
8586
$this->assertEquals($expectedHasher->hash('foo',''),$hasher->hash('foo',''));
8687
}
8788

89+
publicfunctiontestGetHasherConfiguredWithAuto()
90+
{
91+
$factory =newPasswordHasherFactory([
92+
'auto' => ['algorithm' =>'auto'],
93+
]);
94+
95+
$hasher =$factory->getPasswordHasher('auto');
96+
$this->assertInstanceOf(PasswordHasherInterface::class,$hasher);
97+
}
98+
8899
publicfunctiontestGetNamedHasherForHasherAware()
89100
{
90101
$factory =newPasswordHasherFactory([

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp