From 753c4c5ff1ad53d522cc4310b6b5176581bce2dd Mon Sep 17 00:00:00 2001 From: epriestley Date: Sun, 21 Jan 2018 08:09:53 -0800 Subject: [PATCH] Remove the "PhabricatorRepositoryVCSPassword" class and table Summary: Ref T13043. After D18898, this has been migrated to new, more modern storage and no longer has any readers or writers. One migration from long ago (early 2014) is affected. Since this is ancient and the cost of dropping this is small (see inline), I just dropped it. I'll note this in the changelog. Test Plan: Ran migrations, got a clean bill of health from `storage status`. Grepped for removed symbol. Reviewers: amckinley Reviewed By: amckinley Maniphest Tasks: T13043 Differential Revision: https://secure.phabricator.com/D18899 --- .../autopatches/20140218.passwords.4.vcs.php | 32 +++------- .../autopatches/20180121.auth.01.vcsnuke.sql | 1 + src/__phutil_library_map__.php | 2 - .../PhabricatorRepositoryVCSPassword.php | 60 ------------------- 4 files changed, 10 insertions(+), 85 deletions(-) create mode 100644 resources/sql/autopatches/20180121.auth.01.vcsnuke.sql delete mode 100644 src/applications/repository/storage/PhabricatorRepositoryVCSPassword.php diff --git a/resources/sql/autopatches/20140218.passwords.4.vcs.php b/resources/sql/autopatches/20140218.passwords.4.vcs.php index 1030775326..c811844c27 100644 --- a/resources/sql/autopatches/20140218.passwords.4.vcs.php +++ b/resources/sql/autopatches/20140218.passwords.4.vcs.php @@ -1,27 +1,13 @@ establishConnection('w'); +// This migration once upgraded VCS password hashing, but the table was +// later removed in 2018 (see T13043). -echo pht('Upgrading password hashing for VCS passwords.')."\n"; +// Since almost four years have passed since this migration, the cost of +// losing this data is very small (users just need to reset their passwords), +// and a version of this migration against the modern schema isn't easy to +// implement or test, just skip the migration. -$best_hasher = PhabricatorPasswordHasher::getBestHasher(); -foreach (new LiskMigrationIterator($table) as $password) { - $id = $password->getID(); - - echo pht('Migrating VCS password %d...', $id)."\n"; - - $input_hash = $password->getPasswordHash(); - $input_envelope = new PhutilOpaqueEnvelope($input_hash); - - $storage_hash = $best_hasher->getPasswordHashForStorage($input_envelope); - - queryfx( - $conn_w, - 'UPDATE %T SET passwordHash = %s WHERE id = %d', - $table->getTableName(), - $storage_hash->openEnvelope(), - $id); -} - -echo pht('Done.')."\n"; +// This means that installs which upgrade from a version of Phabricator +// released prior to Feb 2014 to a version of Phabricator relased after +// Jan 2018 will need to have users reset VCS passwords. diff --git a/resources/sql/autopatches/20180121.auth.01.vcsnuke.sql b/resources/sql/autopatches/20180121.auth.01.vcsnuke.sql new file mode 100644 index 0000000000..b106a2ddd7 --- /dev/null +++ b/resources/sql/autopatches/20180121.auth.01.vcsnuke.sql @@ -0,0 +1 @@ +DROP TABLE {$NAMESPACE}_repository.repository_vcspassword; diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php index 38f97b4900..50f4abc475 100644 --- a/src/__phutil_library_map__.php +++ b/src/__phutil_library_map__.php @@ -3944,7 +3944,6 @@ phutil_register_library_map(array( 'PhabricatorRepositoryURITestCase' => 'applications/repository/storage/__tests__/PhabricatorRepositoryURITestCase.php', 'PhabricatorRepositoryURITransaction' => 'applications/repository/storage/PhabricatorRepositoryURITransaction.php', 'PhabricatorRepositoryURITransactionQuery' => 'applications/repository/query/PhabricatorRepositoryURITransactionQuery.php', - 'PhabricatorRepositoryVCSPassword' => 'applications/repository/storage/PhabricatorRepositoryVCSPassword.php', 'PhabricatorRepositoryWorkingCopyVersion' => 'applications/repository/storage/PhabricatorRepositoryWorkingCopyVersion.php', 'PhabricatorRequestExceptionHandler' => 'aphront/handler/PhabricatorRequestExceptionHandler.php', 'PhabricatorResourceSite' => 'aphront/site/PhabricatorResourceSite.php', @@ -9593,7 +9592,6 @@ phutil_register_library_map(array( 'PhabricatorRepositoryURITestCase' => 'PhabricatorTestCase', 'PhabricatorRepositoryURITransaction' => 'PhabricatorApplicationTransaction', 'PhabricatorRepositoryURITransactionQuery' => 'PhabricatorApplicationTransactionQuery', - 'PhabricatorRepositoryVCSPassword' => 'PhabricatorRepositoryDAO', 'PhabricatorRepositoryWorkingCopyVersion' => 'PhabricatorRepositoryDAO', 'PhabricatorRequestExceptionHandler' => 'AphrontRequestExceptionHandler', 'PhabricatorResourceSite' => 'PhabricatorSite', diff --git a/src/applications/repository/storage/PhabricatorRepositoryVCSPassword.php b/src/applications/repository/storage/PhabricatorRepositoryVCSPassword.php deleted file mode 100644 index 2f5c20cf7e..0000000000 --- a/src/applications/repository/storage/PhabricatorRepositoryVCSPassword.php +++ /dev/null @@ -1,60 +0,0 @@ - array( - 'passwordHash' => 'text128', - ), - self::CONFIG_KEY_SCHEMA => array( - 'key_phid' => array( - 'columns' => array('userPHID'), - 'unique' => true, - ), - ), - ) + parent::getConfiguration(); - } - - public function setPassword( - PhutilOpaqueEnvelope $password, - PhabricatorUser $user) { - $hash_envelope = $this->hashPassword($password, $user); - return $this->setPasswordHash($hash_envelope->openEnvelope()); - } - - public function comparePassword( - PhutilOpaqueEnvelope $password, - PhabricatorUser $user) { - - return PhabricatorPasswordHasher::comparePassword( - $this->getPasswordHashInput($password, $user), - new PhutilOpaqueEnvelope($this->getPasswordHash())); - } - - private function getPasswordHashInput( - PhutilOpaqueEnvelope $password, - PhabricatorUser $user) { - if ($user->getPHID() != $this->getUserPHID()) { - throw new Exception(pht('User does not match password user PHID!')); - } - - $raw_input = PhabricatorHash::digestPassword($password, $user->getPHID()); - return new PhutilOpaqueEnvelope($raw_input); - } - - private function hashPassword( - PhutilOpaqueEnvelope $password, - PhabricatorUser $user) { - - $input_envelope = $this->getPasswordHashInput($password, $user); - - $best_hasher = PhabricatorPasswordHasher::getBestHasher(); - return $best_hasher->getPasswordHashForStorage($input_envelope); - } - -} -- 2.51.2