[icinga-checkins] icinga.org: icingaweb2/master: ExternalBackend: don' t reference more than necessary from the config

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


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

Author: Alexander A. Klimov <alexander.klimov at icinga.com>
Date:   Tue Oct 18 10:17:21 2016 +0200

ExternalBackend: don't reference more than necessary from the config

refs #12164

---

 .../Icinga/Authentication/User/ExternalBackend.php |   21 ++++++++++----------
 1 file changed, 10 insertions(+), 11 deletions(-)

diff --git a/library/Icinga/Authentication/User/ExternalBackend.php b/library/Icinga/Authentication/User/ExternalBackend.php
index d3631dc..38cc27b 100644
--- a/library/Icinga/Authentication/User/ExternalBackend.php
+++ b/library/Icinga/Authentication/User/ExternalBackend.php
@@ -12,13 +12,6 @@ use Icinga\User;
 class ExternalBackend implements UserBackendInterface
 {
     /**
-     * The configuration of this backend
-     *
-     * @var ConfigObject
-     */
-    protected $config;
-
-    /**
      * The name of this backend
      *
      * @var string
@@ -33,14 +26,21 @@ class ExternalBackend implements UserBackendInterface
     protected $stripUsernameRegexp;
 
     /**
+     * The name variable where to read the user from
+     *
+     * @var string|null
+     */
+    protected $usernameEnvvar;
+
+    /**
      * Create new authentication backend of type "external"
      *
      * @param ConfigObject $config
      */
     public function __construct(ConfigObject $config)
     {
-        $this->config = $config;
         $this->stripUsernameRegexp = $config->get('strip_username_regexp');
+        $this->usernameEnvvar = $config->get('username_envvar');
     }
 
     /**
@@ -87,10 +87,9 @@ class ExternalBackend implements UserBackendInterface
      */
     public function authenticate(User $user, $password = null)
     {
-        $usernameEnvvar = $this->config->username_envvar;
-        $username = static::getRemoteUser($usernameEnvvar);
+        $username = static::getRemoteUser($this->usernameEnvvar);
         if ($username !== null) {
-            $user->setExternalUserInformation($username, $usernameEnvvar);
+            $user->setExternalUserInformation($username, $this->usernameEnvvar);
 
             if ($this->stripUsernameRegexp) {
                 $stripped = preg_replace($this->stripUsernameRegexp, '', $username);



More information about the icinga-checkins mailing list