mirror of
https://we.phorge.it/source/phorge.git
synced 2025-02-06 03:48:28 +01:00
Provide more storage space for password hashes and migrate existing hashes to "md5:"
Summary: Ref T4443. Provide more space; remove the hack-glue. Test Plan: Logged out, logged in, inspected database. Reviewers: btrahan Reviewed By: btrahan CC: aran Maniphest Tasks: T4443 Differential Revision: https://secure.phabricator.com/D8269
This commit is contained in:
parent
3c9153079f
commit
5778627e41
3 changed files with 11 additions and 12 deletions
|
@ -0,0 +1,4 @@
|
||||||
|
/* Extend from 32 characters to 128. */
|
||||||
|
|
||||||
|
ALTER TABLE {$NAMESPACE}_user.user
|
||||||
|
CHANGE passwordHash passwordHash VARCHAR(128) COLLATE utf8_bin;
|
|
@ -0,0 +1,5 @@
|
||||||
|
/* Mark all existing password hashes as "Iterated MD5". */
|
||||||
|
|
||||||
|
UPDATE {$NAMESPACE}_user.user
|
||||||
|
SET passwordHash = CONCAT('md5:', passwordHash)
|
||||||
|
WHERE LENGTH(passwordHash) > 0;
|
|
@ -173,8 +173,7 @@ final class PhabricatorUser
|
||||||
|
|
||||||
return PhabricatorPasswordHasher::comparePassword(
|
return PhabricatorPasswordHasher::comparePassword(
|
||||||
$this->getPasswordHashInput($envelope),
|
$this->getPasswordHashInput($envelope),
|
||||||
// TODO: For now, we need to add a prefix.
|
new PhutilOpaqueEnvelope($this->getPasswordHash()));
|
||||||
new PhutilOpaqueEnvelope('md5:'.$this->getPasswordHash()));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private function getPasswordHashInput(PhutilOpaqueEnvelope $password) {
|
private function getPasswordHashInput(PhutilOpaqueEnvelope $password) {
|
||||||
|
@ -188,19 +187,10 @@ final class PhabricatorUser
|
||||||
}
|
}
|
||||||
|
|
||||||
private function hashPassword(PhutilOpaqueEnvelope $password) {
|
private function hashPassword(PhutilOpaqueEnvelope $password) {
|
||||||
|
|
||||||
$hasher = PhabricatorPasswordHasher::getBestHasher();
|
$hasher = PhabricatorPasswordHasher::getBestHasher();
|
||||||
|
|
||||||
$input_envelope = $this->getPasswordHashInput($password);
|
$input_envelope = $this->getPasswordHashInput($password);
|
||||||
$output_envelope = $hasher->getPasswordHashForStorage($input_envelope);
|
return $hasher->getPasswordHashForStorage($input_envelope);
|
||||||
|
|
||||||
// TODO: For now, we need to strip the type prefix until we can upgrade
|
|
||||||
// the storage.
|
|
||||||
|
|
||||||
$raw_output = $output_envelope->openEnvelope();
|
|
||||||
$raw_output = substr($raw_output, strlen('md5:'));
|
|
||||||
|
|
||||||
return new PhutilOpaqueEnvelope($raw_output);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const CSRF_CYCLE_FREQUENCY = 3600;
|
const CSRF_CYCLE_FREQUENCY = 3600;
|
||||||
|
|
Loading…
Add table
Reference in a new issue