Standardize SSH key storage

Summary:
Ref T5833. This fixes a few weird things with this table:

  - A bunch of columns were nullable for no reason.
  - We stored an MD5 hash of the key (unusual) but never used it and callers were responsible for manually populating it.
  - We didn't perform known-key-text lookups by using an index.

Test Plan:
  - Ran migrations.
  - Faked duplicate keys, saw them clean up correctly.
  - Added new keys.
  - Generated new keys.
  - Used `bin/auth-ssh` and `bin/auth-ssh-key`.

Reviewers: btrahan

Reviewed By: btrahan

Subscribers: epriestley

Maniphest Tasks: T5833

Differential Revision: https://secure.phabricator.com/D10805
This commit is contained in:
epriestley
2014-11-07 15:34:44 -08:00
parent a17a368692
commit bf17b12daf
13 changed files with 136 additions and 33 deletions

View File

@@ -73,21 +73,18 @@ final class PhabricatorAuthSSHKeyQuery
if ($this->objectPHIDs !== null) {
$where[] = qsprintf(
$conn_r,
'userPHID IN (%Ls)',
'objectPHID IN (%Ls)',
$this->objectPHIDs);
}
if ($this->keys !== null) {
// TODO: This could take advantage of a better key, and the hashing
// scheme for this table is a bit nonstandard and questionable.
$sql = array();
foreach ($this->keys as $key) {
$sql[] = qsprintf(
$conn_r,
'(keyType = %s AND keyBody = %s)',
'(keyType = %s AND keyIndex = %s)',
$key->getType(),
$key->getBody());
$key->getHash());
}
$where[] = implode(' OR ', $sql);
}