[icinga-checkins] icinga.org: icingaweb2/master: ExternalBackend: make the variable a webserver assigns a username to configurable

git at icinga.org git at icinga.org
Mon Nov 21 08:53:51 CET 2016


Module: icingaweb2
Branch: master
Commit: ce951295d33ccf8b18d62c2347bce8345b8caac2
URL:    https://git.icinga.org/?p=icingaweb2.git;a=commit;h=ce951295d33ccf8b18d62c2347bce8345b8caac2

Author: Alexander A. Klimov <alexander.klimov at icinga.com>
Date:   Mon Oct 17 18:46:00 2016 +0200

ExternalBackend: make the variable a webserver assigns a username to configurable

refs #12164

---

 library/Icinga/Authentication/User/ExternalBackend.php |   13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/library/Icinga/Authentication/User/ExternalBackend.php b/library/Icinga/Authentication/User/ExternalBackend.php
index 7e9f7ba..d3631dc 100644
--- a/library/Icinga/Authentication/User/ExternalBackend.php
+++ b/library/Icinga/Authentication/User/ExternalBackend.php
@@ -12,6 +12,13 @@ use Icinga\User;
 class ExternalBackend implements UserBackendInterface
 {
     /**
+     * The configuration of this backend
+     *
+     * @var ConfigObject
+     */
+    protected $config;
+
+    /**
      * The name of this backend
      *
      * @var string
@@ -32,6 +39,7 @@ class ExternalBackend implements UserBackendInterface
      */
     public function __construct(ConfigObject $config)
     {
+        $this->config = $config;
         $this->stripUsernameRegexp = $config->get('strip_username_regexp');
     }
 
@@ -79,9 +87,10 @@ class ExternalBackend implements UserBackendInterface
      */
     public function authenticate(User $user, $password = null)
     {
-        $username = static::getRemoteUser(null);
+        $usernameEnvvar = $this->config->username_envvar;
+        $username = static::getRemoteUser($usernameEnvvar);
         if ($username !== null) {
-            $user->setExternalUserInformation($username, null);
+            $user->setExternalUserInformation($username, $usernameEnvvar);
 
             if ($this->stripUsernameRegexp) {
                 $stripped = preg_replace($this->stripUsernameRegexp, '', $username);



More information about the icinga-checkins mailing list