8000 bug #40993 [Security] [Security/Core] fix checking for bcrypt (nicola… · symfony/symfony@9b1e941 · GitHub
[go: up one dir, main page]

Skip to content

Commit 9b1e941

Browse files
committed
bug #40993 [Security] [Security/Core] fix checking for bcrypt (nicolas-grekas)
This PR was merged into the 4.4 branch. Discussion ---------- [Security] [Security/Core] fix checking for bcrypt | Q | A | ------------- | --- | Branch? | 4.4 | Bug fix? | yes | New feature? | no | Deprecations? | no | Tickets | - | License | MIT | Doc PR | - Spotted while working on #40920 Because of the logic in the constructor, if bcrypt is used, it's not cast to string. Commits ------- f01ea99 [Security/Core] fix checking for bcrypt
2 parents 061ac77 + f01ea99 commit 9b1e941

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed
< 8000 button class="Button Button--iconOnly Button--invisible" aria-label="Open diff view settings" id=":R1t6lab:" aria-haspopup="true" aria-expanded="false" tabindex="0">

src/Symfony/Component/Security/Core/Encoder/NativePasswordEncoder.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,11 @@ public function __construct(int $opsLimit = null, int $memLimit = null, int $cos
5151
$algos = [1 => \PASSWORD_BCRYPT, '2y' => \PASSWORD_BCRYPT];
5252

5353
if (\defined('PASSWORD_ARGON2I')) {
54-
$this->algo = $algos[2] = $algos['argon2i'] = (string) \PASSWORD_ARGON2I;
54+
$this->algo = $algos[2] = $algos['argon2i'] = \PASSWORD_ARGON2I;
5555
}
5656

5757
if (\defined('PASSWORD_ARGON2ID')) {
58-
$this->algo = $algos[3] = $algos['argon2id'] = (string) \PASSWORD_ARGON2ID;
58+
$this->algo = $algos[3] = $algos['argon2id'] = \PASSWORD_ARGON2ID;
5959
}
6060

6161 7ADA
if (null !== $algo) {
@@ -75,7 +75,7 @@ public function __construct(int $opsLimit = null, int $memLimit = null, int $cos
7575
*/
7676
public function encodePassword($raw, $salt): string
7777
{
78-
if (\strlen($raw) > self::MAX_PASSWORD_LENGTH || ((string) \PASSWORD_BCRYPT === $this->algo && 72 < \strlen($raw))) {
78+
if (\strlen($raw) > self::MAX_PASSWORD_LENGTH || (\PASSWORD_BCRYPT === $this->algo && 72 < \strlen($raw))) {
7979
throw new BadCredentialsException('Invalid password.');
8080
}
8181

0 commit comments

Comments
 (0)
0