Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
The notIn() method now accepts an implementation of PasswordHistoryIn…
…terface in addition to the current string[]. Bumped Composer package dependencies too and minor README updates to demonstrate newer functionality.
- Loading branch information
Showing
8 changed files
with
214 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<?php | ||
|
||
|
||
namespace Ballen\Plexity\Interfaces; | ||
|
||
interface PasswordHistoryInterface | ||
{ | ||
/** | ||
* Checks that the password does not exist in a password history implementation. | ||
* @param string $password The password to check the history against. | ||
* @return boolean Returns true if the password exists in the history. | ||
*/ | ||
public function checkHistory($password); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
<?php | ||
|
||
|
||
namespace Ballen\Plexity\Tests\Implementations; | ||
|
||
use Ballen\Plexity\Interfaces\PasswordHistoryInterface; | ||
|
||
/** | ||
* Class MD5PasswordHistoryStore | ||
* @package Ballen\Plexity\Tests\Implementations | ||
*/ | ||
class MD5PasswordHistoryStore implements PasswordHistoryInterface | ||
{ | ||
|
||
/** | ||
* An array of plain and simple MD5 password hashes. | ||
* (I HIGHLY RECOMMEND YOU USE STRONG ENCRYPTION IN YOUR REAL WORLD APPLICATIONS THOUGH - THIS IS JUST A VERY SIMPLE IMPLEMENTATION EXAMPLE!!!!!) | ||
* @var array | ||
*/ | ||
private $md5Passwords = [ | ||
'dc647eb65e6711e155375218212b3964', # 'Password' | ||
'3ce189cedebda85cc8454c8339091e39', # 'R0seBu9' | ||
]; | ||
|
||
/** | ||
* Converts the plain password into an MD5 hash before checking against our hashed history array. | ||
* @param $plainPassword | ||
* @return bool | ||
*/ | ||
private function hashAndCheckHistory($plainPassword) | ||
{ | ||
$hashedPassword = md5($plainPassword); | ||
return in_array($hashedPassword, $this->md5Passwords); | ||
} | ||
|
||
/** | ||
* @inheritDoc | ||
*/ | ||
public function checkHistory($password) | ||
{ | ||
return $this->hashAndCheckHistory($password); | ||
} | ||
} |
Oops, something went wrong.