mirror of
https://we.phorge.it/source/arcanist.git
synced 2024-11-26 08:42:40 +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:
parent
b9fa71f7e1
commit
b5b1fd62dc
3 changed files with 36 additions and 1 deletions
|
@ -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"',
|
||||||
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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
|
||||||
|
|
|
@ -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) {
|
||||||
|
|
Loading…
Reference in a new issue