mirror of
https://we.phorge.it/source/arcanist.git
synced 2024-11-22 14:52:40 +01:00
Hook up conduit auth.
This commit is contained in:
parent
c97b736a21
commit
c44c4cf988
1 changed files with 25 additions and 3 deletions
|
@ -67,6 +67,17 @@ try {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$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) {
|
||||||
PhutilSymbolLoader::loadClass($config);
|
PhutilSymbolLoader::loadClass($config);
|
||||||
|
@ -117,6 +128,11 @@ try {
|
||||||
$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(
|
||||||
'conduit.connect',
|
'conduit.connect',
|
||||||
|
@ -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',
|
||||||
|
|
Loading…
Reference in a new issue