1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-07-31 22:10:45 +02:00

[ticket/12352] Add legacy passwords driver for sha1 smf type passwords

PHPBB3-12352
This commit is contained in:
Marc Alexander
2014-04-24 21:00:33 +02:00
parent 48679eeff8
commit 2ea45a06e7
6 changed files with 115 additions and 0 deletions

View File

@@ -43,4 +43,12 @@ abstract class base implements driver_interface
{
return true;
}
/**
* @inheritdoc
*/
public function is_legacy()
{
return false;
}
}

View File

@@ -22,6 +22,13 @@ interface driver_interface
*/
public function is_supported();
/**
* Check if hash type is a legacy hash type
*
* @return bool True if it's a legacy hash type, false if not
*/
public function is_legacy();
/**
* Returns the hash prefix
*

View File

@@ -0,0 +1,58 @@
<?php
/**
*
* @package phpBB3
* @copyright (c) 2014 phpBB Group
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
*
*/
namespace phpbb\passwords\driver;
/**
* @package passwords
*/
class sha1_smf extends base
{
const PREFIX = '$smf$';
/**
* @inheritdoc
*/
public function get_prefix()
{
return self::PREFIX;
}
/**
* @inheritdoc
*/
public function is_legacy()
{
return true;
}
/**
* @inheritdoc
*/
public function hash($password, $user_row = '')
{
return (isset($user_row['login_name'])) ? sha1(strtolower($user_row['login_name']) . $password) : false;
}
/**
* @inheritdoc
*/
public function check($password, $hash, $user_row = array())
{
return $hash === $this->hash($password, $user_row);
}
/**
* @inheritdoc
*/
public function get_settings_only($hash, $full = false)
{
return false;
}
}