@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.

Added a Note Credential Type for Passphrase

Summary: Closes T8481.

Test Plan: Verify that in Passphrase > Create an option to create a Note credential exists and credentials of type Note are createable.

Reviewers: epriestley, #blessed_reviewers, eadler, lpriestley

Reviewed By: eadler

Subscribers: joshuaspence, epriestley, Korvin

Maniphest Tasks: T8481

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

authored by

Paul Kassianik and committed by
epriestley
9537f983 5240ae8b

+62 -9
+2
src/__phutil_library_map__.php
··· 1271 1271 'PassphraseCredentialTypeTestCase' => 'applications/passphrase/credentialtype/__tests__/PassphraseCredentialTypeTestCase.php', 1272 1272 'PassphraseCredentialViewController' => 'applications/passphrase/controller/PassphraseCredentialViewController.php', 1273 1273 'PassphraseDAO' => 'applications/passphrase/storage/PassphraseDAO.php', 1274 + 'PassphraseNoteCredentialType' => 'applications/passphrase/credentialtype/PassphraseNoteCredentialType.php', 1274 1275 'PassphrasePasswordCredentialType' => 'applications/passphrase/credentialtype/PassphrasePasswordCredentialType.php', 1275 1276 'PassphrasePasswordKey' => 'applications/passphrase/keys/PassphrasePasswordKey.php', 1276 1277 'PassphraseQueryConduitAPIMethod' => 'applications/passphrase/conduit/PassphraseQueryConduitAPIMethod.php', ··· 4766 4767 'PassphraseCredentialTypeTestCase' => 'PhabricatorTestCase', 4767 4768 'PassphraseCredentialViewController' => 'PassphraseController', 4768 4769 'PassphraseDAO' => 'PhabricatorLiskDAO', 4770 + 'PassphraseNoteCredentialType' => 'PassphraseCredentialType', 4769 4771 'PassphrasePasswordCredentialType' => 'PassphraseCredentialType', 4770 4772 'PassphrasePasswordKey' => 'PassphraseAbstractKey', 4771 4773 'PassphraseQueryConduitAPIMethod' => 'PassphraseConduitAPIMethod',
+10 -6
src/applications/passphrase/controller/PassphraseCredentialEditController.php
··· 47 47 $is_new = true; 48 48 49 49 // Prefill username if provided. 50 - $credential->setUsername($request->getStr('username')); 50 + $credential->setUsername((string)$request->getStr('username')); 51 51 52 52 if (!$request->getStr('isInitialized')) { 53 53 $type->didInitializeNewCredential($viewer, $credential); ··· 151 151 $credential->openTransaction(); 152 152 153 153 if (!$credential->getIsLocked()) { 154 - $xactions[] = id(new PassphraseCredentialTransaction()) 154 + if ($type->shouldRequireUsername()) { 155 + $xactions[] = id(new PassphraseCredentialTransaction()) 155 156 ->setTransactionType($type_username) 156 157 ->setNewValue($v_username); 157 - 158 + } 158 159 // If some value other than a sequence of bullets was provided for 159 160 // the credential, update it. In particular, note that we are 160 161 // explicitly allowing empty secrets: one use case is HTTP auth where ··· 263 264 pht('This credential is permanently locked and can not be edited.')); 264 265 } 265 266 266 - $form 267 + if ($type->shouldRequireUsername()) { 268 + $form 267 269 ->appendChild( 268 270 id(new AphrontFormTextControl()) 269 271 ->setName('username') 270 272 ->setLabel(pht('Login/Username')) 271 273 ->setValue($v_username) 272 274 ->setDisabled($credential_is_locked) 273 - ->setError($e_username)) 274 - ->appendChild( 275 + ->setError($e_username)); 276 + } 277 + $form 278 + ->appendChild( 275 279 $secret_control 276 280 ->setName('secret') 277 281 ->setLabel($type->getSecretLabel())
+5 -3
src/applications/passphrase/controller/PassphraseCredentialViewController.php
··· 182 182 pht('Editable By'), 183 183 $descriptions[PhabricatorPolicyCapability::CAN_EDIT]); 184 184 185 - $properties->addProperty( 186 - pht('Username'), 187 - $credential->getUsername()); 185 + if ($type->shouldRequireUsername()) { 186 + $properties->addProperty( 187 + pht('Username'), 188 + $credential->getUsername()); 189 + } 188 190 189 191 $used_by_phids = PhabricatorEdgeQuery::loadDestinationPHIDs( 190 192 $credential->getPHID(),
+4
src/applications/passphrase/credentialtype/PassphraseCredentialType.php
··· 131 131 return $secret; 132 132 } 133 133 134 + public function shouldRequireUsername() { 135 + return true; 136 + } 137 + 134 138 }
+37
src/applications/passphrase/credentialtype/PassphraseNoteCredentialType.php
··· 1 + <?php 2 + 3 + final class PassphraseNoteCredentialType 4 + extends PassphraseCredentialType { 5 + 6 + const CREDENTIAL_TYPE = 'note'; 7 + const PROVIDES_TYPE = 'provides/note'; 8 + 9 + public function getCredentialType() { 10 + return self::CREDENTIAL_TYPE; 11 + } 12 + 13 + public function getProvidesType() { 14 + return self::PROVIDES_TYPE; 15 + } 16 + 17 + public function getCredentialTypeName() { 18 + return pht('Note'); 19 + } 20 + 21 + public function getCredentialTypeDescription() { 22 + return pht('Store a plaintext note.'); 23 + } 24 + 25 + public function getSecretLabel() { 26 + return pht('Note'); 27 + } 28 + 29 + public function newSecretControl() { 30 + return id(new AphrontFormTextAreaControl()); 31 + } 32 + 33 + public function shouldRequireUsername() { 34 + return false; 35 + } 36 + 37 + }
+4
src/applications/passphrase/editor/PassphraseCredentialTransactionEditor.php
··· 174 174 } 175 175 break; 176 176 case PassphraseCredentialTransaction::TYPE_USERNAME: 177 + $credential_type = $object->getCredentialTypeImplementation(); 178 + if (!$credential_type->shouldRequireUsername()) { 179 + break; 180 + } 177 181 $missing = $this->validateIsEmptyTextField( 178 182 $object->getUsername(), 179 183 $xactions);