diff --git a/core/core.services.yml b/core/core.services.yml index 3697777..51e86db 100644 --- a/core/core.services.yml +++ b/core/core.services.yml @@ -757,11 +757,11 @@ services: # of computers available to crack the hashes. Note that an increase of 1 will # double the time needed for password hashing. password: - class: Drupal\Component\Password\PhpPassword + class: Drupal\Core\Password\PhpPassword arguments: ['%password_hash_cost%', '@drupal7_password'] lazy: true drupal7_password: - class: Drupal\Component\Password\Drupal7Password + class: Drupal\Core\Password\Drupal7Password arguments: [16] lazy: true accept_header_matcher: diff --git a/core/lib/Drupal/Component/Password/Drupal7Password.php b/core/lib/Drupal/Core/Password/Drupal7Password.php similarity index 98% rename from core/lib/Drupal/Component/Password/Drupal7Password.php rename to core/lib/Drupal/Core/Password/Drupal7Password.php index e85757e..92bdd9d 100644 --- a/core/lib/Drupal/Component/Password/Drupal7Password.php +++ b/core/lib/Drupal/Core/Password/Drupal7Password.php @@ -2,10 +2,10 @@ /** * @file - * Contains \Drupal\Component\Password\Drupal7Password. + * Contains \Drupal\Core\Password\Drupal7Password. */ -namespace Drupal\Component\Password; +namespace Drupal\Core\Password; use Drupal\Component\Utility\Crypt; diff --git a/core/lib/Drupal/Component/Password/PasswordInterface.php b/core/lib/Drupal/Core/Password/PasswordInterface.php similarity index 93% rename from core/lib/Drupal/Component/Password/PasswordInterface.php rename to core/lib/Drupal/Core/Password/PasswordInterface.php index aaf9dd9..17aa26d 100644 --- a/core/lib/Drupal/Component/Password/PasswordInterface.php +++ b/core/lib/Drupal/Core/Password/PasswordInterface.php @@ -2,10 +2,10 @@ /** * @file - * Contains \Drupal\Component\Password\PasswordInterface. + * Contains \Drupal\Core\Password\PasswordInterface. */ -namespace Drupal\Component\Password; +namespace Drupal\Core\Password; /** * Secure password hashing functions for user authentication. diff --git a/core/lib/Drupal/Component/Password/PhpPassword.php b/core/lib/Drupal/Core/Password/PhpPassword.php similarity index 86% rename from core/lib/Drupal/Component/Password/PhpPassword.php rename to core/lib/Drupal/Core/Password/PhpPassword.php index e87c7aa..8d74a11 100644 --- a/core/lib/Drupal/Component/Password/PhpPassword.php +++ b/core/lib/Drupal/Core/Password/PhpPassword.php @@ -2,10 +2,10 @@ /** * @file - * Contains \Drupal\Component\Password\PhpPassword. + * Contains \Drupal\Core\Password\PhpPassword. */ -namespace Drupal\Component\Password; +namespace Drupal\Core\Password; /** * Secure password hashing functions based on PHP (>=5.5.0) password hashing @@ -23,16 +23,20 @@ class PhpPassword implements PasswordInterface { /** - * The algorithmic cost that should be used. + * The algorithmic cost that should be used. This is the same 'cost' option as + * is used by the PHP (>= 5.5.0) password_hash() function. * * @var int + * + * @see password_hash(). + * @see http://php.net/manual/en/ref.password.php */ protected $cost; /** * The Drupal 7 password hashing service. * - * @var \Drupal\Component\Password\Drupal7Password + * @var \Drupal\Core\Password\Drupal7Password */ protected $drupal7Password; @@ -41,7 +45,7 @@ class PhpPassword implements PasswordInterface { * * @param int $cost * The algorithmic cost that should be used. - * @param \Drupal\Component\Password\PasswordInterface $drupal7_password + * @param \Drupal\Core\Password\PasswordInterface $drupal7_password * The Drupal7 password hashing service. */ function __construct($cost, PasswordInterface $drupal7_password) { diff --git a/core/modules/migrate/src/MigratePassword.php b/core/modules/migrate/src/MigratePassword.php index 6879a4b..71948ea 100644 --- a/core/modules/migrate/src/MigratePassword.php +++ b/core/modules/migrate/src/MigratePassword.php @@ -7,7 +7,7 @@ namespace Drupal\migrate; -use Drupal\Component\Password\PasswordInterface; +use Drupal\Core\Password\PasswordInterface; use Drupal\migrate\Entity\MigrationInterface; /** @@ -20,7 +20,7 @@ class MigratePassword implements PasswordInterface { /** * The original password service. * - * @var \Drupal\Component\Password\PasswordInterface + * @var \Drupal\Core\Password\PasswordInterface */ protected $originalPassword; @@ -41,7 +41,7 @@ class MigratePassword implements PasswordInterface { /** * Builds the replacement password service class. * - * @param \Drupal\Component\Password\PasswordInterface $original_password + * @param \Drupal\Core\Password\PasswordInterface $original_password * The password object. */ public function __construct(PasswordInterface $original_password) { diff --git a/core/modules/migrate/src/Plugin/migrate/destination/EntityUser.php b/core/modules/migrate/src/Plugin/migrate/destination/EntityUser.php index a383092..34fd890 100644 --- a/core/modules/migrate/src/Plugin/migrate/destination/EntityUser.php +++ b/core/modules/migrate/src/Plugin/migrate/destination/EntityUser.php @@ -9,7 +9,7 @@ use Drupal\Core\Entity\EntityManagerInterface; use Drupal\Core\Entity\EntityStorageInterface; -use Drupal\Component\Password\PasswordInterface; +use Drupal\Core\Password\PasswordInterface; use Drupal\migrate\Entity\MigrationInterface; use Drupal\migrate\MigrateException; use Drupal\migrate\MigratePassword; @@ -26,7 +26,7 @@ class EntityUser extends EntityContentBase { /** * The password service class. * - * @var \Drupal\Component\Password\PasswordInterface + * @var \Drupal\Core\Password\PasswordInterface */ protected $password; @@ -49,7 +49,7 @@ class EntityUser extends EntityContentBase { * The migrate plugin manager. * @param \Drupal\Core\Entity\EntityManagerInterface $entity_manager * The entity manager service. - * @param \Drupal\Component\Password\PasswordInterface $password + * @param \Drupal\Core\Password\PasswordInterface $password * The password service. */ public function __construct(array $configuration, $plugin_id, $plugin_definition, MigrationInterface $migration, EntityStorageInterface $storage, array $bundles, EntityManagerInterface $entity_manager, PasswordInterface $password) { diff --git a/core/modules/user/src/Tests/UserLoginTest.php b/core/modules/user/src/Tests/UserLoginTest.php index faac924..fdbbc99 100644 --- a/core/modules/user/src/Tests/UserLoginTest.php +++ b/core/modules/user/src/Tests/UserLoginTest.php @@ -21,14 +21,14 @@ class UserLoginTest extends WebTestBase { /** * Drupal password hasher service. * - * @var \Drupal\Component\Password\PasswordInterface + * @var \Drupal\Core\Password\PasswordInterface */ private $passwordHasher; /** * Drupal 7 password hasher service. * - * @var \Drupal\Component\Password\PasswordInterface + * @var \Drupal\Core\Password\PasswordInterface */ private $drupal7PasswordHasher; diff --git a/core/modules/user/src/UserAuth.php b/core/modules/user/src/UserAuth.php index 75593ea..0d04512 100644 --- a/core/modules/user/src/UserAuth.php +++ b/core/modules/user/src/UserAuth.php @@ -8,7 +8,7 @@ namespace Drupal\user; use Drupal\Core\Entity\EntityManagerInterface; -use Drupal\Component\Password\PasswordInterface; +use Drupal\Core\Password\PasswordInterface; /** * Validates user authentication credentials. @@ -25,7 +25,7 @@ class UserAuth implements UserAuthInterface { /** * The password hashing service. * - * @var \Drupal\Component\Password\PasswordInterface + * @var \Drupal\Core\Password\PasswordInterface */ protected $passwordChecker; @@ -34,7 +34,7 @@ class UserAuth implements UserAuthInterface { * * @param \Drupal\Core\Entity\EntityManagerInterface $entity_manager * The entity manager. - * @param \Drupal\Component\Password\PasswordInterface $password_checker + * @param \Drupal\Core\Password\PasswordInterface $password_checker * The password service. */ public function __construct(EntityManagerInterface $entity_manager, PasswordInterface $password_checker) { diff --git a/core/modules/user/src/UserStorage.php b/core/modules/user/src/UserStorage.php index 9b47991..4aad5c5 100644 --- a/core/modules/user/src/UserStorage.php +++ b/core/modules/user/src/UserStorage.php @@ -13,7 +13,7 @@ use Drupal\Core\Entity\EntityManagerInterface; use Drupal\Core\Entity\EntityTypeInterface; use Drupal\Core\Entity\Sql\SqlContentEntityStorage; -use Drupal\Component\Password\PasswordInterface; +use Drupal\Core\Password\PasswordInterface; use Drupal\Core\Session\AccountInterface; use Drupal\Core\Language\LanguageManagerInterface; use Symfony\Component\DependencyInjection\ContainerInterface; @@ -29,7 +29,7 @@ class UserStorage extends SqlContentEntityStorage implements UserStorageInterfac /** * Provides the password hashing service object. * - * @var \Drupal\Component\Password\PasswordInterface + * @var \Drupal\Core\Password\PasswordInterface */ protected $password; @@ -44,7 +44,7 @@ class UserStorage extends SqlContentEntityStorage implements UserStorageInterfac * The entity manager. * @param \Drupal\Core\Cache\CacheBackendInterface $cache_backend * Cache backend instance to use. - * @param \Drupal\Component\Password\PasswordInterface $password + * @param \Drupal\Core\Password\PasswordInterface $password * The password hashing service. * @param \Drupal\Core\Language\LanguageManagerInterface $language_manager * The language manager. diff --git a/core/modules/user/tests/modules/user_custom_pass_hash_params_test/user_custom_pass_hash_params_test.services.yml b/core/modules/user/tests/modules/user_custom_pass_hash_params_test/user_custom_pass_hash_params_test.services.yml index c8ced66..56c1281 100644 --- a/core/modules/user/tests/modules/user_custom_pass_hash_params_test/user_custom_pass_hash_params_test.services.yml +++ b/core/modules/user/tests/modules/user_custom_pass_hash_params_test/user_custom_pass_hash_params_test.services.yml @@ -1,7 +1,7 @@ services: password: - class: Drupal\Component\Password\PhpPassword + class: Drupal\Core\Password\PhpPassword arguments: [11, '@drupal7_password'] drupal7_password: - class: Drupal\Component\Password\Drupal7Password + class: Drupal\Core\Password\Drupal7Password arguments: [16] diff --git a/core/modules/user/tests/src/Unit/UserAuthTest.php b/core/modules/user/tests/src/Unit/UserAuthTest.php index 2d6c4af..3699f15 100644 --- a/core/modules/user/tests/src/Unit/UserAuthTest.php +++ b/core/modules/user/tests/src/Unit/UserAuthTest.php @@ -26,7 +26,7 @@ class UserAuthTest extends UnitTestCase { /** * The mocked password service. * - * @var \Drupal\Component\Password\PasswordInterface|\PHPUnit_Framework_MockObject_MockObject + * @var \Drupal\Core\Password\PasswordInterface|\PHPUnit_Framework_MockObject_MockObject */ protected $passwordService; @@ -70,7 +70,7 @@ protected function setUp() { ->with('user') ->will($this->returnValue($this->userStorage)); - $this->passwordService = $this->getMock('Drupal\Component\Password\PasswordInterface'); + $this->passwordService = $this->getMock('Drupal\Core\Password\PasswordInterface'); $this->testUser = $this->getMockBuilder('Drupal\user\Entity\User') ->disableOriginalConstructor() diff --git a/core/tests/Drupal/Tests/Component/Password/Drupal7PasswordTest.php b/core/tests/Drupal/Tests/Core/Password/Drupal7PasswordTest.php similarity index 94% rename from core/tests/Drupal/Tests/Component/Password/Drupal7PasswordTest.php rename to core/tests/Drupal/Tests/Core/Password/Drupal7PasswordTest.php index ce4a347..cb69edf 100644 --- a/core/tests/Drupal/Tests/Component/Password/Drupal7PasswordTest.php +++ b/core/tests/Drupal/Tests/Core/Password/Drupal7PasswordTest.php @@ -2,18 +2,17 @@ /** * @file - * Contains \Drupal\Tests\Component\Password\Drupal7PasswordTest. + * Contains Drupal7PasswordTest.php */ +namespace Drupal\Tests\Core\Password; -namespace Drupal\Tests\Component\Password; - -use Drupal\Component\Password\Drupal7Password; use Drupal\Tests\UnitTestCase; +use Drupal\Core\Password\Drupal7Password; /** * Unit tests for password hashing API. * - * @coversDefaultClass \Drupal\Component\Password\Drupal7Password + * @coversDefaultClass \Drupal\Core\Password\Drupal7Password * @group System */ class Drupal7PasswordTest extends UnitTestCase { @@ -49,7 +48,7 @@ class Drupal7PasswordTest extends UnitTestCase { /** * The password hasher under test. * - * @var \Drupal\Component\Password\Drupal7Password + * @var \Drupal\Core\Password\Drupal7Password */ protected $passwordHasher; diff --git a/core/tests/Drupal/Tests/Component/Password/PhpPasswordTest.php b/core/tests/Drupal/Tests/Core/Password/PhpPasswordTest.php similarity index 92% rename from core/tests/Drupal/Tests/Component/Password/PhpPasswordTest.php rename to core/tests/Drupal/Tests/Core/Password/PhpPasswordTest.php index df31ff3..923da55 100644 --- a/core/tests/Drupal/Tests/Component/Password/PhpPasswordTest.php +++ b/core/tests/Drupal/Tests/Core/Password/PhpPasswordTest.php @@ -5,16 +5,16 @@ * Contains \Drupal\Tests\Core\Password\PhpPasswordTest. */ -namespace Drupal\Tests\Component\Password; +namespace Drupal\Tests\Core\Password; -use Drupal\Component\Password\PhpPassword; -use Drupal\Component\Password\Drupal7Password; +use Drupal\Core\Password\PhpPassword; +use Drupal\Core\Password\Drupal7Password; use Drupal\Tests\UnitTestCase; /** * Unit tests for password hashing API. * - * @coversDefaultClass \Drupal\Component\Password\PhpPassword + * @coversDefaultClass \Drupal\Core\Password\PhpPassword * @group System */ class PhpPasswordTest extends UnitTestCase { @@ -50,7 +50,7 @@ class PhpPasswordTest extends UnitTestCase { /** * The password hasher under test. * - * @var \Drupal\Component\Password\PasswordInterface + * @var \Drupal\Core\Password\PasswordInterface */ protected $passwordHasher; @@ -105,7 +105,7 @@ public function testPasswordHashing() { */ public function testPasswordRehashing() { // Increment the cost from 4 to 5. - $this->passwordHasher = new PhpPassword(5, new \Drupal\Component\Password\Drupal7Password(1)); + $this->passwordHasher = new PhpPassword(5, new Drupal7Password(1)); $this->assertTrue($this->passwordHasher->needsRehash($this->user->getPassword())); // Re-hash the password. $rehashed_password = $this->passwordHasher->hash($this->password);