diff --git a/application/forms/Config/UserBackend/ExternalBackendForm.php b/application/forms/Config/UserBackend/ExternalBackendForm.php index 34519e63b..e21ed426f 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 44cd85eb5..98a180788 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 d90b52a09..8fb397edc 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();