[icinga-checkins] icinga.org: icingaweb2/bugfix/evaluate-redirect_remote_user-12164: setup/ AuthenticationPage: don' t show the warning about external backend configuration if REDIRECT_REMOTE_USER is set

git at icinga.org git at icinga.org
Tue Oct 18 15:39:46 CEST 2016


Module: icingaweb2
Branch: bugfix/evaluate-redirect_remote_user-12164
Commit: d6ac6c8374a4268f746fbcea04f61503c855eb7d
URL:    https://git.icinga.org/?p=icingaweb2.git;a=commit;h=d6ac6c8374a4268f746fbcea04f61503c855eb7d

Author: Alexander A. Klimov <alexander.klimov at icinga.com>
Date:   Tue Oct 18 15:19:13 2016 +0200

setup/AuthenticationPage: don't show the warning about external backend configuration if REDIRECT_REMOTE_USER is set

refs #12164

---

 .../Config/UserBackend/ExternalBackendForm.php     |    2 +-
 .../Icinga/Authentication/User/ExternalBackend.php |    9 +++++++
 .../setup/application/forms/AuthenticationPage.php |   28 +++++++++++++-------
 3 files changed, 28 insertions(+), 11 deletions(-)

diff --git a/application/forms/Config/UserBackend/ExternalBackendForm.php b/application/forms/Config/UserBackend/ExternalBackendForm.php
index 34519e6..e21ed42 100644
--- a/application/forms/Config/UserBackend/ExternalBackendForm.php
+++ b/application/forms/Config/UserBackend/ExternalBackendForm.php
@@ -57,7 +57,7 @@ class ExternalBackendForm extends Form
             )
         );
 
-        foreach (array('REDIRECT_REMOTE_USER', 'REMOTE_USER') as $envvar) {
+        foreach (ExternalBackend::getRemoteUserEnvvars() as $envvar) {
             if (ExternalBackend::getRemoteUser($envvar) !== null) {
                 break;
             }
diff --git a/library/Icinga/Authentication/User/ExternalBackend.php b/library/Icinga/Authentication/User/ExternalBackend.php
index 44cd85e..98a1807 100644
--- a/library/Icinga/Authentication/User/ExternalBackend.php
+++ b/library/Icinga/Authentication/User/ExternalBackend.php
@@ -83,6 +83,15 @@ class ExternalBackend implements UserBackendInterface
         return null;
     }
 
+    /**
+     * Get possible variables where to read the user from
+     *
+     * @return  string[]
+     */
+    public static function getRemoteUserEnvvars()
+    {
+        return array('REDIRECT_REMOTE_USER', 'REMOTE_USER');
+    }
 
     /**
      * {@inheritdoc}
diff --git a/modules/setup/application/forms/AuthenticationPage.php b/modules/setup/application/forms/AuthenticationPage.php
index d90b52a..8fb397e 100644
--- a/modules/setup/application/forms/AuthenticationPage.php
+++ b/modules/setup/application/forms/AuthenticationPage.php
@@ -31,16 +31,24 @@ class AuthenticationPage extends Form
      */
     public function createElements(array $formData)
     {
-        if (isset($formData['type']) && $formData['type'] === 'external'
-            && ExternalBackend::getRemoteUser(null) === null) {
-            $this->info(
-                $this->translate(
-                    'You\'re currently not authenticated using any of the web server\'s authentication '
-                    . 'mechanisms. Make sure you\'ll configure such, otherwise you\'ll not be able to '
-                    . 'log into Icinga Web 2.'
-                ),
-                false
-            );
+        if (isset($formData['type']) && $formData['type'] === 'external') {
+            $hasRemoteUser = false;
+            foreach (ExternalBackend::getRemoteUserEnvvars() as $envvar) {
+                if (ExternalBackend::getRemoteUser($envvar) !== null) {
+                    $hasRemoteUser = true;
+                    break;
+                }
+            }
+            if (! $hasRemoteUser) {
+                $this->info(
+                    $this->translate(
+                        'You\'re currently not authenticated using any of the web server\'s authentication '
+                        . 'mechanisms. Make sure you\'ll configure such, otherwise you\'ll not be able to '
+                        . 'log into Icinga Web 2.'
+                    ),
+                    false
+                );
+            }
         }
 
         $backendTypes = array();



More information about the icinga-checkins mailing list