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

Allow Harbormaster HTTP steps to pass credentials

Summary: Fixes T4590. Use the credentials custom field to allow Harbormaster HTTP requests to include usernames/passwords.

Test Plan: Ran a build plan with credentials, verified they were sent to the remote server.

Reviewers: btrahan

Reviewed By: btrahan

Subscribers: epriestley

Maniphest Tasks: T4590

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

+37 -7
+37 -7
src/applications/harbormaster/step/HarbormasterHTTPRequestBuildStepImplementation.php
··· 18 18 $domain = id(new PhutilURI($uri))->getDomain(); 19 19 } 20 20 21 - return pht( 22 - 'Make an HTTP %s request to %s.', 23 - $this->formatSettingForDescription('method', 'POST'), 24 - $this->formatValueForDescription($domain)); 21 + $method = $this->formatSettingForDescription('method', 'POST'); 22 + $domain = $this->formatValueForDescription($domain); 23 + 24 + if ($this->getSetting('credential')) { 25 + return pht( 26 + 'Make an authenticated HTTP %s request to %s.', 27 + $method, 28 + $domain); 29 + } else { 30 + return pht( 31 + 'Make an HTTP %s request to %s.', 32 + $method, 33 + $domain); 34 + } 25 35 } 26 36 27 37 public function execute( 28 38 HarbormasterBuild $build, 29 39 HarbormasterBuildTarget $build_target) { 30 40 41 + $viewer = PhabricatorUser::getOmnipotentUser(); 31 42 $settings = $this->getSettings(); 32 43 $variables = $build_target->getVariables(); 33 44 ··· 41 52 42 53 $method = nonempty(idx($settings, 'method'), 'POST'); 43 54 44 - list($status, $body, $headers) = id(new HTTPSFuture($uri)) 55 + $future = id(new HTTPSFuture($uri)) 45 56 ->setMethod($method) 46 - ->setTimeout(60) 47 - ->resolve(); 57 + ->setTimeout(60); 58 + 59 + $credential_phid = $this->getSetting('credential'); 60 + if ($credential_phid) { 61 + $key = PassphrasePasswordKey::loadFromPHID( 62 + $credential_phid, 63 + $viewer); 64 + $future->setHTTPBasicAuthCredentials( 65 + $key->getUsernameEnvelope()->openEnvelope(), 66 + $key->getPasswordEnvelope()); 67 + } 68 + 69 + list($status, $body, $headers) = $future->resolve(); 48 70 49 71 $log_body->append($body); 50 72 $log_body->finalize($start); ··· 65 87 'name' => pht('HTTP Method'), 66 88 'type' => 'select', 67 89 'options' => array_fuse(array('POST', 'GET', 'PUT', 'DELETE')), 90 + ), 91 + 'credential' => array( 92 + 'name' => pht('Credentials'), 93 + 'type' => 'credential', 94 + 'credential.type' 95 + => PassphraseCredentialTypePassword::CREDENTIAL_TYPE, 96 + 'credential.provides' 97 + => PassphraseCredentialTypePassword::PROVIDES_TYPE, 68 98 ), 69 99 ); 70 100 }