From c36184c9438c8b7bd4fcda3d232132debfc61237 Mon Sep 17 00:00:00 2001
From: Dan Morrison <dan@coders.co.nz>
Date: Sun, 1 Mar 2015 16:58:34 +1300
Subject: Issue #1285310 by Dan Morrison, PatchRanger: HTTP basic
 authentication settings in the UI

---
 wsclient_ui/wsclient_ui.inc | 43 +++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 43 insertions(+)

diff --git a/wsclient_ui/wsclient_ui.inc b/wsclient_ui/wsclient_ui.inc
index 5ff296a..bb05191 100644
--- a/wsclient_ui/wsclient_ui.inc
+++ b/wsclient_ui/wsclient_ui.inc
@@ -225,6 +225,49 @@ function wsclient_service_form($form, &$form_state, $service, $op = 'edit') {
       '#header' => $header,
     );

+    $settings = $service->settings;
+    // Simply naming the settings here to reflect the internal entity
+    // structure is enough to mean we don't need to worry about serializing
+    // it ourself.
+    $form['settings'] = array(
+      '#tree' => TRUE,
+    );
+    // Input for Authentication (basic) options.
+    $form['settings']['authentication'] = array(
+      '#type' => 'fieldset',
+      '#title' => t('Authentication'),
+    );
+    $form['settings']['authentication']['type'] = array(
+      '#type' => 'select',
+      '#options' => array(
+        'none' => t("None"),
+        'basic' => t("Basic (htauth)"),
+        'oauth2' => t("OAuth2"),
+      ),
+      '#default_value' => isset($settings['authentication']['type']) ? $settings['authentication']['type'] : 'none',
+      '#description' => t('HTAuth requires http_client.module > 7.x-2.4'),
+    );
+    $form['settings']['authentication']['username'] = array(
+      '#type' => 'textfield',
+      '#title' => 'username',
+      '#default_value' => isset($settings['authentication']['username']) ? $settings['authentication']['username'] : '',
+      '#states' => array(
+        'invisible' => array(
+          ':input[name="settings[authentication][type]"]' => array('value' => 'none'),
+        ),
+      ),
+    );
+    $form['settings']['authentication']['password'] = array(
+      '#type' => 'textfield',
+      '#title' => 'password',
+      '#default_value' => isset($settings['authentication']['password']) ? $settings['authentication']['password'] : '',
+      '#states' => array(
+        'invisible' => array(
+          ':input[name="settings[authentication][type]"]' => array('value' => 'none'),
+        ),
+      ),
+    );
+
     // Input for global service parameters.
     $form['global_parameters'] = array(
       '#tree' => TRUE,
--
1.9.3 (Apple Git-50)

