]> khamidou — GitHub mirrors - arcanist.git/commitdiff
Support http basic auth and related configuration
authorBrennan Taylor <brennan@mobiata.com>
Tue, 18 Dec 2012 01:58:53 +0000 (17:58 -0800)
committerepriestley <git@epriestley.com>
Tue, 18 Dec 2012 02:06:54 +0000 (18:06 -0800)
This adds the http basic auth username and password if found in the
configuration to the ConduitClient.

Reviewed by: epriestley

src/configuration/ArcanistSettings.php
src/workflow/ArcanistBaseWorkflow.php
src/workflow/ArcanistInstallCertificateWorkflow.php

index c8ecb2e6c9696ec159b1117056f948a9425c474f..e2057ed7da3b6414e0f511e468e913c68fc3538e 100644 (file)
@@ -82,6 +82,18 @@ final class ArcanistSettings {
         'help' => 'List of event listener classes to install at startup.',
         '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"',
+      ),
     );
   }
 
index fa62c6e6e21e9246a636c1fb1d2c493bd1eb734d..37ea3f6f121bdf8f8fed38b602b7d2a5f76b713b 100644 (file)
@@ -171,9 +171,32 @@ abstract class ArcanistBaseWorkflow {
       $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;
   }
 
+  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
index 5d05892ae5f3b4913881f7b82353a86c9fcf9029..dc48684d98c07da0dd7f0c540d43f30e177cf09b 100644 (file)
@@ -58,7 +58,7 @@ EOTEXT
     $config = self::readUserConfigurationFile();
 
     echo "Trying to connect to server...\n";
-    $conduit = new ConduitClient($uri);
+    $conduit = $this->establishConduit()->getConduit();
     try {
       $conduit->callMethodSynchronous('conduit.ping', array());
     } catch (Exception $ex) {