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

Hook up conduit auth.

This commit is contained in:
epriestley 2011-02-05 22:44:30 -08:00
parent c97b736a21
commit c44c4cf988

View file

@ -66,6 +66,17 @@ try {
phutil_load_library($library_root); phutil_load_library($library_root);
} }
} }
$user_config = array();
$user_config_path = getenv('HOME').'/.arcrc';
if (Filesystem::pathExists($user_config_path)) {
$user_config_data = Filesystem::readFile($user_config_path);
$user_config = json_decode($user_config_data, true);
if (!is_array($user_config)) {
throw new ArcanistUsageException(
"Your '~/.arcrc' file is not a valid JSON file.");
}
}
$config = $working_copy->getConfig('arcanist_configuration'); $config = $working_copy->getConfig('arcanist_configuration');
if ($config) { if ($config) {
@ -116,6 +127,11 @@ try {
$conduit = new ConduitClient($conduit_uri); $conduit = new ConduitClient($conduit_uri);
$conduit->setTraceMode($config_trace_mode); $conduit->setTraceMode($config_trace_mode);
$workflow->setConduit($conduit); $workflow->setConduit($conduit);
$hosts_config = idx($user_config, 'hosts', array());
$host_config = idx($hosts_config, $conduit_uri, array());
$user_name = idx($host_config, 'user', getenv('USER'));
$certificate = idx($host_config, 'cert');
$description = implode(' ', $argv); $description = implode(' ', $argv);
$connection = $conduit->callMethodSynchronous( $connection = $conduit->callMethodSynchronous(
@ -124,9 +140,15 @@ try {
'client' => 'arc', 'client' => 'arc',
'clientVersion' => 2, 'clientVersion' => 2,
'clientDescription' => php_uname('n').':'.$description, 'clientDescription' => php_uname('n').':'.$description,
'user' => getenv('USER'), 'user' => $user_name,
'certificate' => $certificate,
)); ));
$conduit->setConnectionID($connection['connectionID']);
$workflow->setUserName($user_name);
$user_phid = idx($connection, 'userPHID');
if ($user_phid) {
$workflow->setUserGUID($user_phid);
}
} }
if ($need_repository_api) { if ($need_repository_api) {
@ -135,7 +157,7 @@ try {
$workflow->setRepositoryAPI($repository_api); $workflow->setRepositoryAPI($repository_api);
} }
if ($need_auth) { if ($need_auth && !$workflow->getUserGUID()) {
$user_name = getenv('USER'); $user_name = getenv('USER');
$user_find_future = $conduit->callMethod( $user_find_future = $conduit->callMethod(
'user.find', 'user.find',