Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

[Security] fixed interface implementation (closes #6974)

  • Loading branch information...
commit f02a0c86b6264fc461fc86d39704579439445d3e 1 parent 43ddef9
@fabpot fabpot authored
View
4 Core/Encoder/BCryptPasswordEncoder.php
@@ -58,7 +58,7 @@ public function __construct(SecureRandomInterface $secureRandom, $cost)
/**
* {@inheritdoc}
*/
- public function encodePassword($raw, $salt = null)
+ public function encodePassword($raw, $salt)
{
if (function_exists('password_hash')) {
return password_hash($raw, PASSWORD_BCRYPT, array('cost' => $this->cost));
@@ -76,7 +76,7 @@ public function encodePassword($raw, $salt = null)
/**
* {@inheritdoc}
*/
- public function isPasswordValid($encoded, $raw, $salt = null)
+ public function isPasswordValid($encoded, $raw, $salt)
{
if (function_exists('password_verify')) {
return password_verify($raw, $encoded);
View
12 Tests/Core/Encoder/BCryptPasswordEncoderTest.php
@@ -66,16 +66,16 @@ public function testCostInRange()
public function testResultLength()
{
$encoder = new BCryptPasswordEncoder($this->secureRandom, self::VALID_COST);
- $result = $encoder->encodePassword(self::PASSWORD);
+ $result = $encoder->encodePassword(self::PASSWORD, null);
$this->assertEquals(60, strlen($result));
}
public function testValidation()
{
$encoder = new BCryptPasswordEncoder($this->secureRandom, self::VALID_COST);
- $result = $encoder->encodePassword(self::PASSWORD);
- $this->assertTrue($encoder->isPasswordValid($result, self::PASSWORD));
- $this->assertFalse($encoder->isPasswordValid($result, 'anotherPassword'));
+ $result = $encoder->encodePassword(self::PASSWORD, null);
+ $this->assertTrue($encoder->isPasswordValid($result, self::PASSWORD, null));
+ $this->assertFalse($encoder->isPasswordValid($result, 'anotherPassword', null));
}
public function testValidationKnownPassword()
@@ -85,7 +85,7 @@ public function testValidationKnownPassword()
? '2y' : '2a').'$';
$encrypted = $prefix.'04$ABCDEFGHIJKLMNOPQRSTU.uTmwd4KMSHxbUsG7bng8x7YdA0PM1iq';
- $this->assertTrue($encoder->isPasswordValid($encrypted, self::PASSWORD));
+ $this->assertTrue($encoder->isPasswordValid($encrypted, self::PASSWORD, null));
}
public function testSecureRandomIsUsed()
@@ -100,7 +100,7 @@ public function testSecureRandomIsUsed()
;
$encoder = new BCryptPasswordEncoder($this->secureRandom, self::VALID_COST);
- $result = $encoder->encodePassword(self::PASSWORD);
+ $result = $encoder->encodePassword(self::PASSWORD, null);
$prefix = '$'.(version_compare(phpversion(), '5.3.7', '>=')
? '2y' : '2a').'$';
Please sign in to comment.
Something went wrong with that request. Please try again.