From 1d5848a6aaaaa63311d817f85deca9cf129531fd Mon Sep 17 00:00:00 2001 From: fiwswe <53953985+fiwswe@users.noreply.github.com> Date: Wed, 21 Sep 2022 23:37:57 +0200 Subject: [PATCH] =?utf8?q?Replace=20direct=20access=20to=20$=5FSERVER=20wi?= =?utf8?q?th=20$INPUT->server->=E2=80=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit 2nd try on a separate branch Also fixes a line that was too long Note: As I do not use this plugin, this is completely untested. It should fix splitbrain#3778 (unless I made a stupid mistake). See https://github.com/fiwswe/dokuwiki/commit/ce0feb5f5c38d0e698bd162105fbe61ceb27fca8 --- lib/plugins/authad/auth.php | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/lib/plugins/authad/auth.php b/lib/plugins/authad/auth.php index 05d3a11bd..8090b5670 100644 --- a/lib/plugins/authad/auth.php +++ b/lib/plugins/authad/auth.php @@ -97,21 +97,22 @@ class auth_plugin_authad extends DokuWiki_Auth_Plugin } // Prepare SSO - if (!empty($_SERVER['REMOTE_USER'])) { + if (!empty($INPUT->server->str('REMOTE_USER'))) { // make sure the right encoding is used if ($this->getConf('sso_charset')) { - $_SERVER['REMOTE_USER'] = iconv($this->getConf('sso_charset'), 'UTF-8', $_SERVER['REMOTE_USER']); - } elseif (!\dokuwiki\Utf8\Clean::isUtf8($_SERVER['REMOTE_USER'])) { - $_SERVER['REMOTE_USER'] = utf8_encode($_SERVER['REMOTE_USER']); + $INPUT->server->set('REMOTE_USER', + iconv($this->getConf('sso_charset'), 'UTF-8', $INPUT->server->str('REMOTE_USER'))); + } elseif (!\dokuwiki\Utf8\Clean::isUtf8($INPUT->server->str('REMOTE_USER'))) { + $INPUT->server->set('REMOTE_USER', utf8_encode($INPUT->server->str('REMOTE_USER'))); } // trust the incoming user if ($this->conf['sso']) { - $_SERVER['REMOTE_USER'] = $this->cleanUser($_SERVER['REMOTE_USER']); + $INPUT->server->set('REMOTE_USER', $this->cleanUser($INPUT->server->str('REMOTE_USER'))); // we need to simulate a login if (empty($_COOKIE[DOKU_COOKIE])) { - $INPUT->set('u', $_SERVER['REMOTE_USER']); + $INPUT->set('u', $INPUT->server->str('REMOTE_USER')); $INPUT->set('p', 'sso_only'); } } @@ -131,8 +132,9 @@ class auth_plugin_authad extends DokuWiki_Auth_Plugin */ public function canDo($cap) { + global $INPUT; //capabilities depend on config, which may change depending on domain - $domain = $this->getUserDomain($_SERVER['REMOTE_USER']); + $domain = $this->getUserDomain($INPUT->server->str('REMOTE_USER')); $this->loadServerConfig($domain); return parent::canDo($cap); } @@ -151,8 +153,8 @@ class auth_plugin_authad extends DokuWiki_Auth_Plugin */ public function checkPass($user, $pass) { - if ($_SERVER['REMOTE_USER'] && - $_SERVER['REMOTE_USER'] == $user && + global $INPUT; + if ($INPUT->server->str('REMOTE_USER') == $user && $this->conf['sso'] ) return true; @@ -197,6 +199,7 @@ class auth_plugin_authad extends DokuWiki_Auth_Plugin global $conf; global $lang; global $ID; + global $INPUT; $adldap = $this->initAdLdap($this->getUserDomain($user)); if (!$adldap) return array(); @@ -262,7 +265,7 @@ class auth_plugin_authad extends DokuWiki_Auth_Plugin $info['expiresin'] = round(($info['expiresat'] - time())/(24*60*60)); // if this is the current user, warn him (once per request only) - if (($_SERVER['REMOTE_USER'] == $user) && + if (($INPUT->server->str('REMOTE_USER') == $user) && ($info['expiresin'] <= $this->conf['expirywarn']) && !$this->msgshown ) { -- 2.11.4.GIT