@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Passphrase - added "looked at secret" transaction.

Summary: Fixes T4376. Only thing I don't like in the current implementation is clicking "Done" doesn't refresh the page so you don't see the viewed secret transaction until you reload. Also made the textarea read-only as when I was playing with this for the first time I assumed I could also edit from the view secret side of things.

Test Plan: Viewed some secrets, saw some transactions.

Reviewers: epriestley

Reviewed By: epriestley

CC: Korvin, epriestley, aran

Maniphest Tasks: T4376

Differential Revision: https://secure.phabricator.com/D8345

+26 -1
+12
src/applications/passphrase/controller/PassphraseCredentialRevealController.php
··· 35 35 ->appendChild( 36 36 id(new AphrontFormTextAreaControl()) 37 37 ->setLabel(pht('Plaintext')) 38 + ->setReadOnly(true) 38 39 ->setValue($credential->getSecret()->openEnvelope())); 39 40 } else { 40 41 $body = pht('This credential has no associated secret.'); ··· 45 46 ->setTitle(pht('Credential Secret')) 46 47 ->appendChild($body) 47 48 ->addCancelButton($view_uri, pht('Done')); 49 + 50 + $type_secret = PassphraseCredentialTransaction::TYPE_LOOKEDATSECRET; 51 + $xactions = array(id(new PassphraseCredentialTransaction()) 52 + ->setTransactionType($type_secret) 53 + ->setNewValue(true)); 54 + 55 + $editor = id(new PassphraseCredentialTransactionEditor()) 56 + ->setActor($viewer) 57 + ->setContinueOnNoEffect(true) 58 + ->setContentSourceFromRequest($request) 59 + ->applyTransactions($credential, $xactions); 48 60 49 61 return id(new AphrontDialogResponse())->setDialog($dialog); 50 62 }
+7
src/applications/passphrase/editor/PassphraseCredentialTransactionEditor.php
··· 14 14 $types[] = PassphraseCredentialTransaction::TYPE_USERNAME; 15 15 $types[] = PassphraseCredentialTransaction::TYPE_SECRET_ID; 16 16 $types[] = PassphraseCredentialTransaction::TYPE_DESTROY; 17 + $types[] = PassphraseCredentialTransaction::TYPE_LOOKEDATSECRET; 17 18 18 19 return $types; 19 20 } ··· 35 36 return $object->getSecretID(); 36 37 case PassphraseCredentialTransaction::TYPE_DESTROY: 37 38 return $object->getIsDestroyed(); 39 + case PassphraseCredentialTransaction::TYPE_LOOKEDATSECRET: 40 + return null; 38 41 } 39 42 40 43 return parent::getCustomTransactionOldValue($object, $xaction); ··· 49 52 case PassphraseCredentialTransaction::TYPE_USERNAME: 50 53 case PassphraseCredentialTransaction::TYPE_SECRET_ID: 51 54 case PassphraseCredentialTransaction::TYPE_DESTROY: 55 + case PassphraseCredentialTransaction::TYPE_LOOKEDATSECRET: 52 56 return $xaction->getNewValue(); 53 57 } 54 58 return parent::getCustomTransactionNewValue($object, $xaction); ··· 92 96 case PhabricatorTransactions::TYPE_EDIT_POLICY: 93 97 $object->setEditPolicy($xaction->getNewValue()); 94 98 return; 99 + case PassphraseCredentialTransaction::TYPE_LOOKEDATSECRET: 100 + return; 95 101 } 96 102 97 103 return parent::applyCustomInternalTransaction($object, $xaction); ··· 107 113 case PassphraseCredentialTransaction::TYPE_USERNAME: 108 114 case PassphraseCredentialTransaction::TYPE_SECRET_ID: 109 115 case PassphraseCredentialTransaction::TYPE_DESTROY: 116 + case PassphraseCredentialTransaction::TYPE_LOOKEDATSECRET: 110 117 case PhabricatorTransactions::TYPE_VIEW_POLICY: 111 118 case PhabricatorTransactions::TYPE_EDIT_POLICY: 112 119 return;
+7 -1
src/applications/passphrase/storage/PassphraseCredentialTransaction.php
··· 8 8 const TYPE_USERNAME = 'passphrase:username'; 9 9 const TYPE_SECRET_ID = 'passphrase:secretID'; 10 10 const TYPE_DESTROY = 'passphrase:destroy'; 11 + const TYPE_LOOKEDATSECRET = 'passphrase:lookedAtSecret'; 11 12 12 13 public function getApplicationName() { 13 14 return 'passphrase'; ··· 28 29 return ($old === null); 29 30 case self::TYPE_USERNAME: 30 31 return !strlen($old); 32 + case self::TYPE_LOOKEDATSECRET: 33 + return false; 31 34 } 32 35 return parent::shouldHide(); 33 36 } ··· 77 80 return pht( 78 81 '%s destroyed this credential.', 79 82 $this->renderHandleLink($author_phid)); 83 + case self::TYPE_LOOKEDATSECRET: 84 + return pht( 85 + '%s examined the secret plaintext for this credential.', 86 + $this->renderHandleLink($author_phid)); 80 87 } 81 88 82 89 return parent::getTitle(); ··· 96 103 json_encode($this->getOldValue()), 97 104 json_encode($this->getNewValue())); 98 105 } 99 - 100 106 101 107 }