From d34a2a38603431bc5caa74b726a6f58d86a70530 Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Tue, 22 Oct 2013 21:45:37 +0200 Subject: allow charset for SSO to be configured FS#2148 --- lib/plugins/authad/auth.php | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) (limited to 'lib/plugins/authad/auth.php') diff --git a/lib/plugins/authad/auth.php b/lib/plugins/authad/auth.php index fcbd2eeef..e1d758fb8 100644 --- a/lib/plugins/authad/auth.php +++ b/lib/plugins/authad/auth.php @@ -92,16 +92,24 @@ class auth_plugin_authad extends DokuWiki_Auth_Plugin { } // Prepare SSO - if(!utf8_check($_SERVER['REMOTE_USER'])) { - $_SERVER['REMOTE_USER'] = utf8_encode($_SERVER['REMOTE_USER']); - } - if($_SERVER['REMOTE_USER'] && $this->conf['sso']) { - $_SERVER['REMOTE_USER'] = $this->cleanUser($_SERVER['REMOTE_USER']); + if(!empty($_SERVER['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(!utf8_check($_SERVER['REMOTE_USER'])) { + $_SERVER['REMOTE_USER'] = utf8_encode($_SERVER['REMOTE_USER']); + } - // we need to simulate a login - if(empty($_COOKIE[DOKU_COOKIE])) { - $INPUT->set('u', $_SERVER['REMOTE_USER']); - $INPUT->set('p', 'sso_only'); + // trust the incoming user + if($this->conf['sso']) { + $_SERVER['REMOTE_USER'] = $this->cleanUser($_SERVER['REMOTE_USER']); + + // we need to simulate a login + if(empty($_COOKIE[DOKU_COOKIE])) { + $INPUT->set('u', $_SERVER['REMOTE_USER']); + $INPUT->set('p', 'sso_only'); + } } } -- cgit v1.2.3 From 741b8a48682890ee68e3f650510fec9a4d47d5b0 Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Fri, 14 Feb 2014 13:57:50 +0100 Subject: Show a domain dropdown when multiple AD domains are configured This integrates the functionality of the now outdated addomain plugin directly into the authad plugin and makes multi-domain setups usable without SSO. See also https://github.com/cosmocode/dokuwiki-plugin-addomain --- lib/plugins/authad/auth.php | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'lib/plugins/authad/auth.php') diff --git a/lib/plugins/authad/auth.php b/lib/plugins/authad/auth.php index e1d758fb8..db9b179a6 100644 --- a/lib/plugins/authad/auth.php +++ b/lib/plugins/authad/auth.php @@ -511,6 +511,31 @@ class auth_plugin_authad extends DokuWiki_Auth_Plugin { return $opts; } + /** + * Returns a list of configured domains + * + * The default domain has an empty string as key + * + * @return array associative array(key => domain) + */ + public function _getConfiguredDomains() { + $domains = array(); + if(empty($this->conf['account_suffix'])) return $domains; // not configured yet + + // add default domain, using the name from account suffix + $domains[''] = ltrim($this->conf['account_suffix'], '@'); + + // find additional domains + foreach($this->conf as $key => $val) { + if(is_array($val) && isset($val['account_suffix'])) { + $domains[$key] = ltrim($val['account_suffix'], '@'); + } + } + ksort($domains); + + return $domains; + } + /** * Check provided user and userinfo for matching patterns * -- cgit v1.2.3 From 9a2c73e86d2549a2cd63d7f772b4bb1a3956e46f Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Sat, 15 Feb 2014 12:36:15 +0100 Subject: streamlined retrieveUsers() signature over all auth plugins FS#2919 --- lib/plugins/authad/auth.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'lib/plugins/authad/auth.php') diff --git a/lib/plugins/authad/auth.php b/lib/plugins/authad/auth.php index e1d758fb8..7e2d902bd 100644 --- a/lib/plugins/authad/auth.php +++ b/lib/plugins/authad/auth.php @@ -332,7 +332,7 @@ class auth_plugin_authad extends DokuWiki_Auth_Plugin { * @param array $filter array of field/pattern pairs, null for no filter * @return array userinfo (refer getUserData for internal userinfo details) */ - public function retrieveUsers($start = 0, $limit = -1, $filter = array()) { + public function retrieveUsers($start = 0, $limit = 0, $filter = array()) { $adldap = $this->_adldap(null); if(!$adldap) return false; @@ -357,7 +357,7 @@ class auth_plugin_authad extends DokuWiki_Auth_Plugin { } if($this->_filter($user, $info)) { $result[$user] = $info; - if(($limit >= 0) && (++$count >= $limit)) break; + if(($limit > 0) && (++$count >= $limit)) break; } } return $result; -- cgit v1.2.3 From 0ba750c06b51626ccace39f0f6be7062eebb0a40 Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Sat, 15 Feb 2014 13:52:37 +0100 Subject: fixed retrieveUser function in authad previously it never returned any users --- lib/plugins/authad/auth.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/plugins/authad/auth.php') diff --git a/lib/plugins/authad/auth.php b/lib/plugins/authad/auth.php index 7e2d902bd..a0fec7b52 100644 --- a/lib/plugins/authad/auth.php +++ b/lib/plugins/authad/auth.php @@ -336,7 +336,7 @@ class auth_plugin_authad extends DokuWiki_Auth_Plugin { $adldap = $this->_adldap(null); if(!$adldap) return false; - if($this->users === null) { + if(!$this->users) { //get info for given user $result = $adldap->user()->all(); if (!$result) return array(); -- cgit v1.2.3