1
0
Fork 0
mirror of https://we.phorge.it/source/arcanist.git synced 2024-11-22 23:02:41 +01:00

Support http basic auth and related configuration

This adds the http basic auth username and password if found in the
configuration to the ConduitClient.

Reviewed by: epriestley
This commit is contained in:
Brennan Taylor 2012-12-17 17:58:53 -08:00 committed by epriestley
parent b9fa71f7e1
commit b5b1fd62dc
3 changed files with 36 additions and 1 deletions

View file

@ -82,6 +82,18 @@ final class ArcanistSettings {
'help' => 'List of event listener classes to install at startup.', 'help' => 'List of event listener classes to install at startup.',
'example' => '["ExampleEventListener"]', 'example' => '["ExampleEventListener"]',
), ),
'http.basicauth.user' => array(
'type' => 'string',
'help' =>
"Username to use for basic auth over http transports",
'example' => '"bob"',
),
'http.basicauth.pass' => array(
'type' => 'string',
'help' =>
"Password to use for basic auth over http transports",
'example' => '"bobhasasecret"',
),
); );
} }

View file

@ -171,9 +171,32 @@ abstract class ArcanistBaseWorkflow {
$this->conduit->setTimeout($this->conduitTimeout); $this->conduit->setTimeout($this->conduitTimeout);
} }
$user = $this->getConfigFromWhateverSourceAvailiable('http.basicauth.user');
$pass = $this->getConfigFromWhateverSourceAvailiable('http.basicauth.pass');
if ($user !== null && $pass !== null) {
$this->conduit->setBasicAuthCredentials($user, $pass);
}
return $this; return $this;
} }
final public function getConfigFromWhateverSourceAvailiable($key) {
if ($this->requiresWorkingCopy()) {
$working_copy = $this->getWorkingCopy();
return $working_copy->getConfigFromAnySource($key);
} else {
$global_config = self::readGlobalArcConfig();
$pval = idx($global_config, $key);
if ($pval === null) {
$system_config = self::readSystemArcConfig();
$pval = idx($system_config, $key);
}
return $pval;
}
}
/** /**
* Set credentials which will be used to authenticate against Conduit. These * Set credentials which will be used to authenticate against Conduit. These

View file

@ -58,7 +58,7 @@ EOTEXT
$config = self::readUserConfigurationFile(); $config = self::readUserConfigurationFile();
echo "Trying to connect to server...\n"; echo "Trying to connect to server...\n";
$conduit = new ConduitClient($uri); $conduit = $this->establishConduit()->getConduit();
try { try {
$conduit->callMethodSynchronous('conduit.ping', array()); $conduit->callMethodSynchronous('conduit.ping', array());
} catch (Exception $ex) { } catch (Exception $ex) {