mirror of
https://github.com/phpbb/phpbb.git
synced 2025-01-19 07:08:09 +01:00
[feature/passwords] Rename "crypto" files to "passwords" files
PHPBB3-11610
This commit is contained in:
parent
b810957c4b
commit
19512b2595
@ -1,54 +0,0 @@
|
||||
parameters:
|
||||
password_hashing.algorithm: crypto.driver.bcrypt_2y
|
||||
|
||||
services:
|
||||
crypto.driver.bcrypt:
|
||||
class: phpbb_crypto_driver_bcrypt
|
||||
arguments:
|
||||
- @config
|
||||
calls:
|
||||
- [set_name, [crypto.driver.bcrypt]]
|
||||
tags:
|
||||
- { name: crypto.driver }
|
||||
|
||||
crypto.driver.bcrypt_2y:
|
||||
class: phpbb_crypto_driver_bcrypt_2y
|
||||
arguments:
|
||||
- @config
|
||||
calls:
|
||||
- [set_name, [crypto.driver.bcrypt_2y]]
|
||||
tags:
|
||||
- { name: crypto.driver }
|
||||
|
||||
crypto.driver.salted_md5:
|
||||
class: phpbb_crypto_driver_salted_md5
|
||||
arguments:
|
||||
- @config
|
||||
calls:
|
||||
- [set_name, [crypto.driver.salted_md5]]
|
||||
tags:
|
||||
- { name: crypto.driver }
|
||||
|
||||
crypto.driver.phpass:
|
||||
class: phpbb_crypto_driver_phpass
|
||||
arguments:
|
||||
- @config
|
||||
calls:
|
||||
- [set_name, [crypto.driver.phpass]]
|
||||
tags:
|
||||
- { name: crypto.driver }
|
||||
|
||||
crypto.driver_collection:
|
||||
class: phpbb_di_service_collection
|
||||
arguments:
|
||||
- @service_container
|
||||
tags:
|
||||
- { name: service_collection, tag: crypto.driver }
|
||||
|
||||
crypto.manager:
|
||||
class: phpbb_crypto_manager
|
||||
arguments:
|
||||
- @config
|
||||
- @service_container
|
||||
- @crypto.driver_collection
|
||||
- %password_hashing.algorithm%
|
54
phpBB/config/passwords.yml
Normal file
54
phpBB/config/passwords.yml
Normal file
@ -0,0 +1,54 @@
|
||||
parameters:
|
||||
passwords.algorithm: passwords.driver.bcrypt_2y
|
||||
|
||||
services:
|
||||
passwords.driver.bcrypt:
|
||||
class: phpbb_passwords_driver_bcrypt
|
||||
arguments:
|
||||
- @config
|
||||
calls:
|
||||
- [set_name, [passwords.driver.bcrypt]]
|
||||
tags:
|
||||
- { name: passwords.driver }
|
||||
|
||||
passwords.driver.bcrypt_2y:
|
||||
class: phpbb_passwords_driver_bcrypt_2y
|
||||
arguments:
|
||||
- @config
|
||||
calls:
|
||||
- [set_name, [passwords.driver.bcrypt_2y]]
|
||||
tags:
|
||||
- { name: passwords.driver }
|
||||
|
||||
passwords.driver.salted_md5:
|
||||
class: phpbb_passwords_driver_salted_md5
|
||||
arguments:
|
||||
- @config
|
||||
calls:
|
||||
- [set_name, [passwords.driver.salted_md5]]
|
||||
tags:
|
||||
- { name: passwords.driver }
|
||||
|
||||
passwords.driver.phpass:
|
||||
class: phpbb_passwords_driver_phpass
|
||||
arguments:
|
||||
- @config
|
||||
calls:
|
||||
- [set_name, [passwords.driver.phpass]]
|
||||
tags:
|
||||
- { name: passwords.driver }
|
||||
|
||||
passwords.driver_collection:
|
||||
class: phpbb_di_service_collection
|
||||
arguments:
|
||||
- @service_container
|
||||
tags:
|
||||
- { name: service_collection, tag: passwords.driver }
|
||||
|
||||
passwords.manager:
|
||||
class: phpbb_passwords_manager
|
||||
arguments:
|
||||
- @config
|
||||
- @service_container
|
||||
- @passwords.driver_collection
|
||||
- %passwords.algorithm%
|
@ -6,7 +6,7 @@ imports:
|
||||
- { resource: avatars.yml }
|
||||
- { resource: feed.yml }
|
||||
- { resource: auth_providers.yml }
|
||||
- { resource: crypto.yml }
|
||||
- { resource: passwords.yml }
|
||||
|
||||
services:
|
||||
acl.permissions:
|
||||
|
@ -16,28 +16,28 @@ if (!defined('IN_PHPBB'))
|
||||
}
|
||||
|
||||
/**
|
||||
* @package crypto
|
||||
* @package passwords
|
||||
*/
|
||||
abstract class phpbb_crypto_driver_base implements phpbb_crypto_driver_interface
|
||||
abstract class phpbb_passwords_driver_base implements phpbb_passwords_driver_interface
|
||||
{
|
||||
/** @var phpbb_config */
|
||||
protected $config;
|
||||
|
||||
/** @var phpbb_crypto_driver_helper */
|
||||
/** @var phpbb_passwords_driver_helper */
|
||||
protected $helper;
|
||||
|
||||
/** @var driver name */
|
||||
protected $name;
|
||||
|
||||
/**
|
||||
* Constructor of crypto driver object
|
||||
* Constructor of passwords driver object
|
||||
*
|
||||
* @return string Hash prefix
|
||||
*/
|
||||
public function __construct(phpbb_config $config)
|
||||
{
|
||||
$this->config = $config;
|
||||
$this->helper = new phpbb_crypto_driver_helper($this);
|
||||
$this->helper = new phpbb_passwords_driver_helper($this);
|
||||
}
|
||||
|
||||
/**
|
@ -16,9 +16,9 @@ if (!defined('IN_PHPBB'))
|
||||
}
|
||||
|
||||
/**
|
||||
* @package crypto
|
||||
* @package passwords
|
||||
*/
|
||||
class phpbb_crypto_driver_bcrypt extends phpbb_crypto_driver_base
|
||||
class phpbb_passwords_driver_bcrypt extends phpbb_passwords_driver_base
|
||||
{
|
||||
const PREFIX = '$2a$';
|
||||
|
@ -16,9 +16,9 @@ if (!defined('IN_PHPBB'))
|
||||
}
|
||||
|
||||
/**
|
||||
* @package crypto
|
||||
* @package passwords
|
||||
*/
|
||||
class phpbb_crypto_driver_bcrypt_2y extends phpbb_crypto_driver_bcrypt
|
||||
class phpbb_passwords_driver_bcrypt_2y extends phpbb_passwords_driver_bcrypt
|
||||
{
|
||||
const PREFIX = '$2y$';
|
||||
|
@ -16,9 +16,9 @@ if (!defined('IN_PHPBB'))
|
||||
}
|
||||
|
||||
/**
|
||||
* @package crypto
|
||||
* @package passwords
|
||||
*/
|
||||
class phpbb_crypto_driver_helper
|
||||
class phpbb_passwords_driver_helper
|
||||
{
|
||||
/** @var phpbb_config */
|
||||
protected $driver;
|
||||
@ -30,7 +30,7 @@ class phpbb_crypto_driver_helper
|
||||
public $itoa64 = './0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz';
|
||||
|
||||
/**
|
||||
* Constructor of crypto driver helper object
|
||||
* Constructor of passwords driver helper object
|
||||
*/
|
||||
public function __construct($driver)
|
||||
{
|
@ -16,9 +16,9 @@ if (!defined('IN_PHPBB'))
|
||||
}
|
||||
|
||||
/**
|
||||
* @package crypto
|
||||
* @package passwords
|
||||
*/
|
||||
interface phpbb_crypto_driver_interface
|
||||
interface phpbb_passwords_driver_interface
|
||||
{
|
||||
/**
|
||||
* Check if hash type is supported
|
@ -16,9 +16,9 @@ if (!defined('IN_PHPBB'))
|
||||
}
|
||||
|
||||
/**
|
||||
* @package crypto
|
||||
* @package passwords
|
||||
*/
|
||||
class phpbb_crypto_driver_phpass extends phpbb_crypto_driver_salted_md5
|
||||
class phpbb_passwords_driver_phpass extends phpbb_passwords_driver_salted_md5
|
||||
{
|
||||
const PREFIX = '$P$';
|
||||
|
@ -16,9 +16,9 @@ if (!defined('IN_PHPBB'))
|
||||
}
|
||||
|
||||
/**
|
||||
* @package crypto
|
||||
* @package passwords
|
||||
*/
|
||||
class phpbb_crypto_driver_salted_md5 extends phpbb_crypto_driver_base
|
||||
class phpbb_passwords_driver_salted_md5 extends phpbb_passwords_driver_base
|
||||
{
|
||||
const PREFIX = '$H$';
|
||||
|
@ -16,12 +16,12 @@ if (!defined('IN_PHPBB'))
|
||||
}
|
||||
|
||||
/**
|
||||
* @package crypto
|
||||
* @package passwords
|
||||
*/
|
||||
class phpbb_crypto_helper
|
||||
class phpbb_passwords_helper
|
||||
{
|
||||
/**
|
||||
* @var phpbb_crypto_manager
|
||||
* @var phpbb_passwords_manager
|
||||
*/
|
||||
protected $manager;
|
||||
|
||||
@ -31,9 +31,9 @@ class phpbb_crypto_helper
|
||||
protected $container;
|
||||
|
||||
/**
|
||||
* Construct a phpbb_crypto_helper object
|
||||
* Construct a phpbb_passwords_helper object
|
||||
*
|
||||
* @param phpbb_crypto_manager $manager Crypto manager object
|
||||
* @param phpbb_passwords_manager $manager Crypto manager object
|
||||
* @param phpbb_container $container phpBB container object
|
||||
*/
|
||||
public function __construct($manager, $container)
|
@ -16,9 +16,9 @@ if (!defined('IN_PHPBB'))
|
||||
}
|
||||
|
||||
/**
|
||||
* @package crypto
|
||||
* @package passwords
|
||||
*/
|
||||
class phpbb_crypto_manager
|
||||
class phpbb_passwords_manager
|
||||
{
|
||||
/**
|
||||
* Default hashing method
|
||||
@ -37,7 +37,7 @@ class phpbb_crypto_manager
|
||||
|
||||
/**
|
||||
* Crypto helper
|
||||
* @var phpbb_crypto_helper
|
||||
* @var phpbb_passwords_helper
|
||||
*/
|
||||
protected $helper;
|
||||
|
||||
@ -54,7 +54,7 @@ class phpbb_crypto_manager
|
||||
protected $container;
|
||||
|
||||
/**
|
||||
* Construct a crypto object
|
||||
* Construct a passwords object
|
||||
*
|
||||
* @param phpbb_config $config phpBB configuration
|
||||
*/
|
||||
@ -65,7 +65,7 @@ class phpbb_crypto_manager
|
||||
$this->type = $default;
|
||||
|
||||
$this->fill_type_map($hashing_algorithms);
|
||||
$this->load_crypto_helper();
|
||||
$this->load_passwords_helper();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -85,13 +85,13 @@ class phpbb_crypto_manager
|
||||
}
|
||||
|
||||
/**
|
||||
* Load crypto helper class
|
||||
* Load passwords helper class
|
||||
*/
|
||||
protected function load_crypto_helper()
|
||||
protected function load_passwords_helper()
|
||||
{
|
||||
if ($this->helper === null)
|
||||
{
|
||||
$this->helper = new phpbb_crypto_helper($this, $this->container);
|
||||
$this->helper = new phpbb_passwords_helper($this, $this->container);
|
||||
}
|
||||
}
|
||||
|
||||
@ -170,7 +170,7 @@ class phpbb_crypto_manager
|
||||
|
||||
$hashing_algorithm = $this->container->get($type);
|
||||
// Do not support 8-bit characters with $2a$ bcrypt
|
||||
if ($type === 'crypto.driver.bcrypt' || ($type === 'crypto.driver.bcrypt_2y' && !$hashing_algorithm->is_supported()))
|
||||
if ($type === 'passwords.driver.bcrypt' || ($type === 'passwords.driver.bcrypt_2y' && !$hashing_algorithm->is_supported()))
|
||||
{
|
||||
if (ord($password[strlen($password)-1]) & 128)
|
||||
{
|
@ -8,15 +8,15 @@
|
||||
*/
|
||||
|
||||
require_once dirname(__FILE__) . '/../mock/container_builder.php';
|
||||
require_once dirname(__FILE__) . '/../../phpBB/phpbb/crypto/driver/bcrypt.php';
|
||||
require_once dirname(__FILE__) . '/../../phpBB/phpbb/crypto/driver/bcrypt_2y.php';
|
||||
require_once dirname(__FILE__) . '/../../phpBB/phpbb/crypto/driver/salted_md5.php';
|
||||
require_once dirname(__FILE__) . '/../../phpBB/phpbb/crypto/driver/phpass.php';
|
||||
require_once dirname(__FILE__) . '/../../phpBB/phpbb/crypto/driver/helper.php';
|
||||
require_once dirname(__FILE__) . '/../../phpBB/phpbb/passwords/driver/bcrypt.php';
|
||||
require_once dirname(__FILE__) . '/../../phpBB/phpbb/passwords/driver/bcrypt_2y.php';
|
||||
require_once dirname(__FILE__) . '/../../phpBB/phpbb/passwords/driver/salted_md5.php';
|
||||
require_once dirname(__FILE__) . '/../../phpBB/phpbb/passwords/driver/phpass.php';
|
||||
require_once dirname(__FILE__) . '/../../phpBB/phpbb/passwords/driver/helper.php';
|
||||
|
||||
class phpbb_crypto_manager_test extends PHPUnit_Framework_TestCase
|
||||
class phpbb_passwords_manager_test extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
protected $crypto_drivers;
|
||||
protected $passwords_drivers;
|
||||
|
||||
protected $pw_characters = '0123456789abcdefghijklmnopqrstuvwyzABCDEFGHIJKLMNOPQRSTUVXYZ.,_!?/\\';
|
||||
|
||||
@ -32,21 +32,21 @@ class phpbb_crypto_manager_test extends PHPUnit_Framework_TestCase
|
||||
// Prepare dependencies for manager and driver
|
||||
$config = new phpbb_config(array());
|
||||
|
||||
$this->crypto_drivers = array(
|
||||
'crypto.driver.bcrypt' => new phpbb_crypto_driver_bcrypt($config),
|
||||
'crypto.driver.bcrypt_2y' => new phpbb_crypto_driver_bcrypt_2y($config),
|
||||
'crypto.driver.salted_md5' => new phpbb_crypto_driver_salted_md5($config),
|
||||
'crypto.driver.phpass' => new phpbb_crypto_driver_phpass($config),
|
||||
$this->passwords_drivers = array(
|
||||
'passwords.driver.bcrypt' => new phpbb_passwords_driver_bcrypt($config),
|
||||
'passwords.driver.bcrypt_2y' => new phpbb_passwords_driver_bcrypt_2y($config),
|
||||
'passwords.driver.salted_md5' => new phpbb_passwords_driver_salted_md5($config),
|
||||
'passwords.driver.phpass' => new phpbb_passwords_driver_phpass($config),
|
||||
);
|
||||
|
||||
foreach ($this->crypto_drivers as $key => $driver)
|
||||
foreach ($this->passwords_drivers as $key => $driver)
|
||||
{
|
||||
$driver->set_name($key);
|
||||
$this->phpbb_container->set($key, $driver);
|
||||
}
|
||||
|
||||
// Set up avatar manager
|
||||
$this->manager = new phpbb_crypto_manager($config, $this->phpbb_container, $this->crypto_drivers, 'crypto.driver.bcrypt_2y');
|
||||
$this->manager = new phpbb_passwords_manager($config, $this->phpbb_container, $this->passwords_drivers, 'passwords.driver.bcrypt_2y');
|
||||
}
|
||||
|
||||
public function hash_password_data()
|
||||
@ -55,18 +55,18 @@ class phpbb_crypto_manager_test extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
return array(
|
||||
array('', '2a', 60),
|
||||
array('crypto.driver.bcrypt_2y', '2a', 60),
|
||||
array('crypto.driver.bcrypt', '2a', 60),
|
||||
array('crypto.driver.salted_md5', 'H', 34),
|
||||
array('passwords.driver.bcrypt_2y', '2a', 60),
|
||||
array('passwords.driver.bcrypt', '2a', 60),
|
||||
array('passwords.driver.salted_md5', 'H', 34),
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
return array(
|
||||
array('', '2y', 60),
|
||||
array('crypto.driver.bcrypt_2y', '2y', 60),
|
||||
array('crypto.driver.bcrypt', '2a', 60),
|
||||
array('crypto.driver.salted_md5', 'H', 34),
|
||||
array('passwords.driver.bcrypt_2y', '2y', 60),
|
||||
array('passwords.driver.bcrypt', '2a', 60),
|
||||
array('passwords.driver.salted_md5', 'H', 34),
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -95,18 +95,18 @@ class phpbb_crypto_manager_test extends PHPUnit_Framework_TestCase
|
||||
if (version_compare(PHP_VERSION, '5.3.7', '<'))
|
||||
{
|
||||
return array(
|
||||
array('crypto.driver.bcrypt'),
|
||||
array('crypto.driver.salted_md5'),
|
||||
array('crypto.driver.phpass'),
|
||||
array('passwords.driver.bcrypt'),
|
||||
array('passwords.driver.salted_md5'),
|
||||
array('passwords.driver.phpass'),
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
return array(
|
||||
array('crypto.driver.bcrypt_2y'),
|
||||
array('crypto.driver.bcrypt'),
|
||||
array('crypto.driver.salted_md5'),
|
||||
array('crypto.driver.phpass'),
|
||||
array('passwords.driver.bcrypt_2y'),
|
||||
array('passwords.driver.bcrypt'),
|
||||
array('passwords.driver.salted_md5'),
|
||||
array('passwords.driver.phpass'),
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -128,7 +128,7 @@ class phpbb_crypto_manager_test extends PHPUnit_Framework_TestCase
|
||||
}
|
||||
|
||||
// Check if convert_flag is correctly set
|
||||
$this->assertEquals(($hash_type !== 'crypto.driver.bcrypt_2y'), $this->manager->convert_flag);
|
||||
$this->assertEquals(($hash_type !== 'passwords.driver.bcrypt_2y'), $this->manager->convert_flag);
|
||||
}
|
||||
|
||||
|
||||
@ -154,7 +154,7 @@ class phpbb_crypto_manager_test extends PHPUnit_Framework_TestCase
|
||||
|
||||
public function test_hash_password_length()
|
||||
{
|
||||
foreach ($this->crypto_drivers as $driver)
|
||||
foreach ($this->passwords_drivers as $driver)
|
||||
{
|
||||
$this->assertEquals(false, $driver->hash('foobar', 'foobar'));
|
||||
}
|
||||
@ -162,7 +162,7 @@ class phpbb_crypto_manager_test extends PHPUnit_Framework_TestCase
|
||||
|
||||
public function test_hash_password_8bit_bcrypt()
|
||||
{
|
||||
$this->assertEquals(false, $this->manager->hash_password('foobar𝄞', 'crypto.driver.bcrypt'));
|
||||
$this->assertEquals(false, $this->manager->hash_password('foobar𝄞', 'passwords.driver.bcrypt'));
|
||||
}
|
||||
|
||||
public function test_combined_hash_data()
|
||||
@ -171,20 +171,20 @@ class phpbb_crypto_manager_test extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
return array(
|
||||
array(
|
||||
'crypto.driver.salted_md5',
|
||||
array('crypto.driver.bcrypt'),
|
||||
'passwords.driver.salted_md5',
|
||||
array('passwords.driver.bcrypt'),
|
||||
),
|
||||
array(
|
||||
'crypto.driver.phpass',
|
||||
array('crypto.driver.salted_md5'),
|
||||
'passwords.driver.phpass',
|
||||
array('passwords.driver.salted_md5'),
|
||||
),
|
||||
array(
|
||||
'crypto.driver.salted_md5',
|
||||
array('crypto.driver.phpass', 'crypto.driver.bcrypt'),
|
||||
'passwords.driver.salted_md5',
|
||||
array('passwords.driver.phpass', 'passwords.driver.bcrypt'),
|
||||
),
|
||||
array(
|
||||
'crypto.driver.salted_md5',
|
||||
array('crypto.driver.salted_md5'),
|
||||
'passwords.driver.salted_md5',
|
||||
array('passwords.driver.salted_md5'),
|
||||
false,
|
||||
),
|
||||
);
|
||||
@ -193,24 +193,24 @@ class phpbb_crypto_manager_test extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
return array(
|
||||
array(
|
||||
'crypto.driver.salted_md5',
|
||||
array('crypto.driver.bcrypt_2y'),
|
||||
'passwords.driver.salted_md5',
|
||||
array('passwords.driver.bcrypt_2y'),
|
||||
),
|
||||
array(
|
||||
'crypto.driver.salted_md5',
|
||||
array('crypto.driver.bcrypt'),
|
||||
'passwords.driver.salted_md5',
|
||||
array('passwords.driver.bcrypt'),
|
||||
),
|
||||
array(
|
||||
'crypto.driver.phpass',
|
||||
array('crypto.driver.salted_md5'),
|
||||
'passwords.driver.phpass',
|
||||
array('passwords.driver.salted_md5'),
|
||||
),
|
||||
array(
|
||||
'crypto.driver.salted_md5',
|
||||
array('crypto.driver.bcrypt_2y', 'crypto.driver.bcrypt'),
|
||||
'passwords.driver.salted_md5',
|
||||
array('passwords.driver.bcrypt_2y', 'passwords.driver.bcrypt'),
|
||||
),
|
||||
array(
|
||||
'crypto.driver.salted_md5',
|
||||
array('crypto.driver.salted_md5'),
|
||||
'passwords.driver.salted_md5',
|
||||
array('passwords.driver.salted_md5'),
|
||||
false,
|
||||
),
|
||||
);
|
Loading…
x
Reference in New Issue
Block a user