diff --git a/src/OAuth2/Storage/Cassandra.php b/src/OAuth2/Storage/Cassandra.php index f8596ceb0..5f7068af0 100644 --- a/src/OAuth2/Storage/Cassandra.php +++ b/src/OAuth2/Storage/Cassandra.php @@ -182,7 +182,13 @@ public function checkUserCredentials($username, $password) // plaintext passwords are bad! Override this for your application protected function checkPassword($user, $password) { - return $user['password'] == sha1($password); + return $user['password'] == $this->hashPassword($password); + } + + // use a secure hashing algorithm when storing passwords. Override this for your application + protected function hashPassword($password) + { + return sha1($password); } public function getUserDetails($username) @@ -204,7 +210,7 @@ public function getUser($username) public function setUser($username, $password, $first_name = null, $last_name = null) { - $password = sha1($password); + $password = $this->hashPassword($password); return $this->setValue( $this->config['user_key'] . $username, diff --git a/src/OAuth2/Storage/DynamoDB.php b/src/OAuth2/Storage/DynamoDB.php index d7f729276..a1d35baff 100644 --- a/src/OAuth2/Storage/DynamoDB.php +++ b/src/OAuth2/Storage/DynamoDB.php @@ -342,7 +342,13 @@ public function unsetRefreshToken($refresh_token) // plaintext passwords are bad! Override this for your application protected function checkPassword($user, $password) { - return $user['password'] == sha1($password); + return $user['password'] == $this->hashPassword($password); + } + + // use a secure hashing algorithm when storing passwords. Override this for your application + protected function hashPassword($password) + { + return sha1($password); } public function getUser($username) @@ -363,7 +369,7 @@ public function getUser($username) public function setUser($username, $password, $first_name = null, $last_name = null) { // do not store in plaintext - $password = sha1($password); + $password = $this->hashPassword($password); $clientData = compact('username', 'password', 'first_name', 'last_name'); $clientData = array_filter($clientData, 'self::isNotEmpty'); diff --git a/src/OAuth2/Storage/Pdo.php b/src/OAuth2/Storage/Pdo.php index 9b030b058..f8948835b 100644 --- a/src/OAuth2/Storage/Pdo.php +++ b/src/OAuth2/Storage/Pdo.php @@ -307,7 +307,13 @@ public function unsetRefreshToken($refresh_token) // plaintext passwords are bad! Override this for your application protected function checkPassword($user, $password) { - return $user['password'] == sha1($password); + return $user['password'] == $this->hashPassword($password); + } + + // use a secure hashing algorithm when storing passwords. Override this for your application + protected function hashPassword($password) + { + return sha1($password); } public function getUser($username) @@ -328,7 +334,7 @@ public function getUser($username) public function setUser($username, $password, $firstName = null, $lastName = null) { // do not store in plaintext - $password = sha1($password); + $password = $this->hashPassword($password); // if it exists, update it. if ($this->getUser($username)) {