Skip to content

Commit

Permalink
Fail on empty password verification (without warning on any implement…
Browse files Browse the repository at this point in the history
…ation)
  • Loading branch information
Stefan Kruppa authored and fabpot committed Feb 3, 2020
1 parent ed7bb82 commit 4d920f0
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 0 deletions.
Expand Up @@ -76,6 +76,9 @@ public function encodePassword($raw, $salt): string
*/
public function isPasswordValid($encoded, $raw, $salt): bool
{
if ('' === $raw) {
return false;
}
if (\strlen($raw) > self::MAX_PASSWORD_LENGTH) {
return false;
}
Expand Down
Expand Up @@ -76,6 +76,9 @@ public function encodePassword($raw, $salt): string
*/
public function isPasswordValid($encoded, $raw, $salt): bool
{
if ('' === $raw) {
return false;
}
if (\strlen($raw) > self::MAX_PASSWORD_LENGTH) {
return false;
}
Expand Down
Expand Up @@ -53,6 +53,7 @@ public function testValidation()
$result = $encoder->encodePassword('password', null);
$this->assertTrue($encoder->isPasswordValid($result, 'password', null));
$this->assertFalse($encoder->isPasswordValid($result, 'anotherPassword', null));
$this->assertFalse($encoder->isPasswordValid($result, '', null));
}

public function testNonArgonValidation()
Expand Down
Expand Up @@ -29,6 +29,7 @@ public function testValidation()
$result = $encoder->encodePassword('password', null);
$this->assertTrue($encoder->isPasswordValid($result, 'password', null));
$this->assertFalse($encoder->isPasswordValid($result, 'anotherPassword', null));
$this->assertFalse($encoder->isPasswordValid($result, '', null));
}

public function testBCryptValidation()
Expand Down

0 comments on commit 4d920f0

Please sign in to comment.