From 8c62c66a4ec99baf59489719c228adcf1f1c3ce2 Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Mon, 20 Oct 2014 15:14:14 +0200 Subject: [PATCH] Make regular expression pattern in autologin backend being fully optional --- .../forms/Config/Authentication/AutologinBackendForm.php | 1 - application/forms/Setup/AdminAccountPage.php | 2 +- library/Icinga/Authentication/Backend/AutoLoginBackend.php | 2 +- 3 files changed, 2 insertions(+), 3 deletions(-) diff --git a/application/forms/Config/Authentication/AutologinBackendForm.php b/application/forms/Config/Authentication/AutologinBackendForm.php index 05e1f201d..757db4b70 100644 --- a/application/forms/Config/Authentication/AutologinBackendForm.php +++ b/application/forms/Config/Authentication/AutologinBackendForm.php @@ -50,7 +50,6 @@ class AutologinBackendForm extends Form 'text', 'strip_username_regexp', array( - 'required' => true, 'label' => t('Backend Domain Pattern'), 'description' => t('The domain pattern of this authentication backend'), 'value' => '/\@[^$]+$/', diff --git a/application/forms/Setup/AdminAccountPage.php b/application/forms/Setup/AdminAccountPage.php index 6734ab766..c2e23090a 100644 --- a/application/forms/Setup/AdminAccountPage.php +++ b/application/forms/Setup/AdminAccountPage.php @@ -220,7 +220,7 @@ class AdminAccountPage extends Form } $name = $_SERVER['REMOTE_USER']; - if (isset($this->backendConfig['strip_username_regexp'])) { + if (isset($this->backendConfig['strip_username_regexp']) && $this->backendConfig['strip_username_regexp']) { // No need to silence or log anything here because the pattern has // already been successfully compiled during backend configuration $name = preg_replace($this->backendConfig['strip_username_regexp'], '', $name); diff --git a/library/Icinga/Authentication/Backend/AutoLoginBackend.php b/library/Icinga/Authentication/Backend/AutoLoginBackend.php index 16373bb6c..271db702e 100644 --- a/library/Icinga/Authentication/Backend/AutoLoginBackend.php +++ b/library/Icinga/Authentication/Backend/AutoLoginBackend.php @@ -54,7 +54,7 @@ class AutoLoginBackend extends UserBackend if (isset($_SERVER['REMOTE_USER'])) { $username = $_SERVER['REMOTE_USER']; $user->setRemoteUserInformation($username, 'REMOTE_USER'); - if ($this->stripUsernameRegexp !== null) { + if ($this->stripUsernameRegexp) { $stripped = preg_replace($this->stripUsernameRegexp, '', $username); if ($stripped !== false) { // TODO(el): PHP issues a warning when PHP cannot compile the regular expression. Should we log an