186e0f1b9SPhilipp Neuser<?php 286e0f1b9SPhilipp Neuser// must be run within Dokuwiki 386e0f1b9SPhilipp Neuserif(!defined('DOKU_INC')) die(); 486e0f1b9SPhilipp Neuser 586e0f1b9SPhilipp Neuser/** 686e0f1b9SPhilipp Neuser* Chained authentication backend 786e0f1b9SPhilipp Neuser* 886e0f1b9SPhilipp Neuser* @license GPL 2 (http://www.gnu.org/licenses/gpl.html) 986e0f1b9SPhilipp Neuser* @author Philipp Nesuer <pneuser@physik.fu-berlin.de> 1086e0f1b9SPhilipp Neuser*/ 1186e0f1b9SPhilipp Neuserclass auth_plugin_authchained extends DokuWiki_Auth_Plugin { 1286e0f1b9SPhilipp Neuser public $success = true; 13*32fe206aSeinhirn //array with authentication plugins 1486e0f1b9SPhilipp Neuser protected $chained_plugins = array(); 1586e0f1b9SPhilipp Neuser protected $chained_auth = NULL; 1686e0f1b9SPhilipp Neuser 1786e0f1b9SPhilipp Neuser /** 1886e0f1b9SPhilipp Neuser * Constructor. 1986e0f1b9SPhilipp Neuser * 2086e0f1b9SPhilipp Neuser * Loads all configured plugins or the authentication plugin of the 2186e0f1b9SPhilipp Neuser * logged in user. 2286e0f1b9SPhilipp Neuser * 2386e0f1b9SPhilipp Neuser * @author Philipp Neuser <pneuser@physik.fu-berlin.de> 2486e0f1b9SPhilipp Neuser */ 2586e0f1b9SPhilipp Neuser public function __construct() { 2686e0f1b9SPhilipp Neuser global $conf; 2786e0f1b9SPhilipp Neuser // call parent 2886e0f1b9SPhilipp Neuser # parent::__constructor(); 2986e0f1b9SPhilipp Neuser 30*32fe206aSeinhirn //check if there is already an authentication plugin selected 319e84dbfbSPhilipp Neuser if( isset($_SESSION[DOKU_COOKIE]['plugin']['authchained']['module']) && 32*32fe206aSeinhirn !empty($_SESSION[DOKU_COOKIE]['plugin']['authchained']['module']) ) { 3386e0f1b9SPhilipp Neuser //get previously selected authentication plugin 349e84dbfbSPhilipp Neuser $tmp_plugin = $_SESSION[DOKU_COOKIE]['plugin']['authchained']['module']; 3586e0f1b9SPhilipp Neuser require_once(DOKU_INC."lib/plugins/".$tmp_plugin."/auth.php"); 3686e0f1b9SPhilipp Neuser $tmp_classname = "auth_plugin_".$tmp_plugin; 3786e0f1b9SPhilipp Neuser $this->chained_auth = new $tmp_classname; 38*32fe206aSeinhirn 39*32fe206aSeinhirn } else { 4086e0f1b9SPhilipp Neuser //get authentication plugins 419e84dbfbSPhilipp Neuser if(isset($conf['plugin']['authchained']['authtypes'])){ 42*32fe206aSeinhirn foreach(explode(":",$conf['plugin']['authchained']['authtypes']) as $tmp_plugin){ 4386e0f1b9SPhilipp Neuser require_once(DOKU_INC."lib/plugins/".$tmp_plugin."/auth.php"); 4486e0f1b9SPhilipp Neuser $tmp_classname = "auth_plugin_".$tmp_plugin; 4586e0f1b9SPhilipp Neuser $tmp_class = new $tmp_classname; 4686e0f1b9SPhilipp Neuser $tmp_module = array($tmp_plugin,$tmp_class); 4786e0f1b9SPhilipp Neuser array_push($this->chained_plugins, $tmp_module); 4886e0f1b9SPhilipp Neuser } 4986e0f1b9SPhilipp Neuser }else{ 5086e0f1b9SPhilipp Neuser $success = false; 5186e0f1b9SPhilipp Neuser } 5286e0f1b9SPhilipp Neuser } 5386e0f1b9SPhilipp Neuser //debug 5486e0f1b9SPhilipp Neuser // print_r($chained_plugins); 5586e0f1b9SPhilipp Neuser } 5686e0f1b9SPhilipp Neuser 5786e0f1b9SPhilipp Neuser /** 5886e0f1b9SPhilipp Neuser * Forwards the authentication to configured authplugins. 5986e0f1b9SPhilipp Neuser * Returns true, if the usermanager authtype has the capability and no user 6086e0f1b9SPhilipp Neuser * is logged in. 6186e0f1b9SPhilipp Neuser * 6286e0f1b9SPhilipp Neuser * @author Philipp Neuser <pneuser@physik.fu-berlin.de> 6386e0f1b9SPhilipp Neuser * @param string $cap the capability to check 6486e0f1b9SPhilipp Neuser * @return bool 6586e0f1b9SPhilipp Neuser */ 6686e0f1b9SPhilipp Neuser public function canDo($cap) { 6786e0f1b9SPhilipp Neuser global $conf; 68c368b833SPhilipp Neuser # print_r($cap); 69*32fe206aSeinhirn if(is_null($this->chained_auth)) { 70*32fe206aSeinhirn foreach($this->chained_plugins as $module) { 7186e0f1b9SPhilipp Neuser #echo "TEST AUTHMANAGER!!!"; 72*32fe206aSeinhirn if($module[0] == $conf['plugin']['authchained']['usermanager_authtype']) { 7386e0f1b9SPhilipp Neuser $module[1]->canDo($cap); 7486e0f1b9SPhilipp Neuser } 7586e0f1b9SPhilipp Neuser } 7686e0f1b9SPhilipp Neuser return false; 77*32fe206aSeinhirn } else { 7886e0f1b9SPhilipp Neuser #echo "canDo $cap ".$this->chained_auth->canDo($cap)."\n"; 7986e0f1b9SPhilipp Neuser return $this->chained_auth->canDo($cap); 8086e0f1b9SPhilipp Neuser } 8186e0f1b9SPhilipp Neuser } 8286e0f1b9SPhilipp Neuser 8386e0f1b9SPhilipp Neuser /** 8486e0f1b9SPhilipp Neuser * Forwards the result of the auth plugin of the logged in user or 8586e0f1b9SPhilipp Neuser * returns false 8686e0f1b9SPhilipp Neuser * 8786e0f1b9SPhilipp Neuser * @author Philipp Neuser <pneuser@physik.fu-berlin.de> 8886e0f1b9SPhilipp Neuser * @param string $type Modification type ('create', 'modify', 'delete') 8986e0f1b9SPhilipp Neuser * @param array $params Parameters for the createUser, modifyUser or deleteUsers method. The content of this array depends on the modification type 9086e0f1b9SPhilipp Neuser * @return mixed Result from the modification function or false if an event handler has canceled the action 9186e0f1b9SPhilipp Neuser */ 9286e0f1b9SPhilipp Neuser public function triggerUserMod($type, $params) { 9386e0f1b9SPhilipp Neuser if(is_null($this->chained_auth)) 9486e0f1b9SPhilipp Neuser return false; 9586e0f1b9SPhilipp Neuser else 96c368b833SPhilipp Neuser return $this->chained_auth->triggerUserMod($type, $params); 9786e0f1b9SPhilipp Neuser } 9886e0f1b9SPhilipp Neuser 9986e0f1b9SPhilipp Neuser /** 10086e0f1b9SPhilipp Neuser * Forwards the result of the auth plugin of the logged in user and 10186e0f1b9SPhilipp Neuser * unsets our session variable. 10286e0f1b9SPhilipp Neuser * @see auth_logoff() 10386e0f1b9SPhilipp Neuser * @author Philipp Neuser <pneuser@physik.fu-berlin.de 10486e0f1b9SPhilipp Neuser */ 10586e0f1b9SPhilipp Neuser public function logOff() { 10686e0f1b9SPhilipp Neuser if(!is_null($this->chained_auth)) 10786e0f1b9SPhilipp Neuser $this->chained_auth->logOff(); 1089e84dbfbSPhilipp Neuser unset($_SESSION[DOKU_COOKIE]['plugin']['authchained']['module']); 10986e0f1b9SPhilipp Neuser } 11086e0f1b9SPhilipp Neuser 11186e0f1b9SPhilipp Neuser /** 11286e0f1b9SPhilipp Neuser * Do all authentication [ OPTIONAL ] 11386e0f1b9SPhilipp Neuser * If the current plugin is external, be external. 11486e0f1b9SPhilipp Neuser * 11586e0f1b9SPhilipp Neuser * @see auth_login() 11686e0f1b9SPhilipp Neuser * @author Philipp Neuser <pneuser@physik.fu-berlin.de> 11786e0f1b9SPhilipp Neuser * 11886e0f1b9SPhilipp Neuser * @param string $user Username 11986e0f1b9SPhilipp Neuser * @param string $pass Cleartext Password 12086e0f1b9SPhilipp Neuser * @param bool $sticky Cookie should not expire 12186e0f1b9SPhilipp Neuser * @return bool true on successful auth 12286e0f1b9SPhilipp Neuser */ 12386e0f1b9SPhilipp Neuser public function trustExternal($user, $pass, $sticky = false) { 12486e0f1b9SPhilipp Neuser if(!is_null($this->chained_auth) && $this->chained_auth->canDo('external')) 12586e0f1b9SPhilipp Neuser $this->chained_auth->trustExternal($user, $pass, $sticky); 12686e0f1b9SPhilipp Neuser } 12786e0f1b9SPhilipp Neuser 12886e0f1b9SPhilipp Neuser /** 12986e0f1b9SPhilipp Neuser * Check user+password [ MUST BE OVERRIDDEN ] 13086e0f1b9SPhilipp Neuser * 13186e0f1b9SPhilipp Neuser * Checks if the given user exists in one of the plugins and checks 13286e0f1b9SPhilipp Neuser * against the given password. The first plugin returning true becomes 13386e0f1b9SPhilipp Neuser * auth plugin of the user session. 13486e0f1b9SPhilipp Neuser * 13586e0f1b9SPhilipp Neuser * @author Philipp Neuser <pneuser@physik.fu-berlin.de 13686e0f1b9SPhilipp Neuser * @param string $user the user name 13786e0f1b9SPhilipp Neuser * @param string $pass the clear text password 13886e0f1b9SPhilipp Neuser * @return bool 13986e0f1b9SPhilipp Neuser */ 14086e0f1b9SPhilipp Neuser public function checkPass($user, $pass) { 14186e0f1b9SPhilipp Neuser //debug 14286e0f1b9SPhilipp Neuser //print_r($this->chained_plugins); 1438a493abfSPhilipp Neuser if(is_null($this->chained_auth)) { 144*32fe206aSeinhirn foreach($this->chained_plugins as $module) { 145*32fe206aSeinhirn if($module[1]->canDo('external')) { 146*32fe206aSeinhirn if($module[1]->trustExternal($user, $pass)) { 147*32fe206aSeinhirn $_SESSION[DOKU_COOKIE]['plugin']['authchained']['module'] = $module[0]; 14886e0f1b9SPhilipp Neuser $this->chained_auth = $module[1]; 14986e0f1b9SPhilipp Neuser return true; 15086e0f1b9SPhilipp Neuser } else { 151*32fe206aSeinhirn if($module[1]->checkPass($user, $pass)) { 152*32fe206aSeinhirn $_SESSION[DOKU_COOKIE]['plugin']['authchained']['module'] = $module[0]; 15386e0f1b9SPhilipp Neuser $this->chained_auth = $module[1]; 15486e0f1b9SPhilipp Neuser return true; 15586e0f1b9SPhilipp Neuser } 15686e0f1b9SPhilipp Neuser } 15786e0f1b9SPhilipp Neuser } else { 158*32fe206aSeinhirn if($module[1]->checkPass($user, $pass)) { 159*32fe206aSeinhirn $_SESSION[DOKU_COOKIE]['plugin']['authchained']['module'] = $module[0]; 16086e0f1b9SPhilipp Neuser $this->this->chained_auth = $module[1]; 16186e0f1b9SPhilipp Neuser return true; 16286e0f1b9SPhilipp Neuser } 16386e0f1b9SPhilipp Neuser } 16486e0f1b9SPhilipp Neuser } 165*32fe206aSeinhirn } else { 166*32fe206aSeinhirn return $this->chained_auth->checkPass($user, $pass); 167*32fe206aSeinhirn } 16886e0f1b9SPhilipp Neuser return false; 16986e0f1b9SPhilipp Neuser } 17086e0f1b9SPhilipp Neuser 17186e0f1b9SPhilipp Neuser /** 17286e0f1b9SPhilipp Neuser * Forwards the result of the auth plugin of the logged in user or 17386e0f1b9SPhilipp Neuser * checks all plugins if the users exists. The first plugin returning 17486e0f1b9SPhilipp Neuser * data is used. 17586e0f1b9SPhilipp Neuser * 17686e0f1b9SPhilipp Neuser * name string full name of the user 17786e0f1b9SPhilipp Neuser * mail string email addres of the user 17886e0f1b9SPhilipp Neuser * grps array list of groups the user is in 17986e0f1b9SPhilipp Neuser * 18086e0f1b9SPhilipp Neuser * @author Philipp Neuser <pneuser@physik.fu-berlin.de> 18186e0f1b9SPhilipp Neuser * @param string $user the user name 18286e0f1b9SPhilipp Neuser * @return array containing user data or false 18386e0f1b9SPhilipp Neuser */ 18486e0f1b9SPhilipp Neuser public function getUserData($user) { 18586e0f1b9SPhilipp Neuser //if(!$this->cando['external']) msg("no valid authorisation system in use", -1); 18686e0f1b9SPhilipp Neuser // echo "TESTSETEST"; 187*32fe206aSeinhirn if(is_null($this->chained_auth)) { 188*32fe206aSeinhirn foreach($this->chained_plugins as $module) { 18986e0f1b9SPhilipp Neuser $tmp_array = $module[1]->getUserData($user); 19086e0f1b9SPhilipp Neuser if(!is_bool($tmp_array)) 19186e0f1b9SPhilipp Neuser $tmp_chk_arr =array_filter($tmp_array); 19286e0f1b9SPhilipp Neuser if(!empty($tmp_chk_arr) && $tmp_array) 19386e0f1b9SPhilipp Neuser return $tmp_array; 19486e0f1b9SPhilipp Neuser } 19586e0f1b9SPhilipp Neuser return false; 196*32fe206aSeinhirn } else { 19786e0f1b9SPhilipp Neuser return $this->chained_auth->getUserData($user); 19886e0f1b9SPhilipp Neuser } 19986e0f1b9SPhilipp Neuser } 20086e0f1b9SPhilipp Neuser 20186e0f1b9SPhilipp Neuser /** 20286e0f1b9SPhilipp Neuser * Forwards the result of the auth plugin of the logged in user or 20386e0f1b9SPhilipp Neuser * returns null. 20486e0f1b9SPhilipp Neuser * 20586e0f1b9SPhilipp Neuser * @author Philipp Neuser <pneuser@physik.fu-berlin.de> 20686e0f1b9SPhilipp Neuser * @param string $user 20786e0f1b9SPhilipp Neuser * @param string $pass 20886e0f1b9SPhilipp Neuser * @param string $name 20986e0f1b9SPhilipp Neuser * @param string $mail 21086e0f1b9SPhilipp Neuser * @param null|array $grps 21186e0f1b9SPhilipp Neuser * @return bool|null 21286e0f1b9SPhilipp Neuser */ 21386e0f1b9SPhilipp Neuser public function createUser($user, $pass, $name, $mail, $grps = null) { 21486e0f1b9SPhilipp Neuser if(is_null($this->chained_auth)) { 215*32fe206aSeinhirn msg("authorisation method does not allow creation of new users", -1); 21686e0f1b9SPhilipp Neuser return null; 217*32fe206aSeinhirn } else { 21886e0f1b9SPhilipp Neuser //please note: users will be added to the module, to which the 21986e0f1b9SPhilipp Neuser //current user is logged into 22086e0f1b9SPhilipp Neuser if($this->canDo('addUser')) { 221*32fe206aSeinhirn return $this->chained_auth->createUser($user, $pass, $name, $mail, $grps); 22286e0f1b9SPhilipp Neuser } else { 223*32fe206aSeinhirn msg("authorisation method does not allow creation of new users", -1); 22486e0f1b9SPhilipp Neuser return null; 22586e0f1b9SPhilipp Neuser } 22686e0f1b9SPhilipp Neuser } 22786e0f1b9SPhilipp Neuser } 22886e0f1b9SPhilipp Neuser 22986e0f1b9SPhilipp Neuser /** 23086e0f1b9SPhilipp Neuser * Forwards the result of the auth plugin of the logged in user or 23186e0f1b9SPhilipp Neuser * returns false 23286e0f1b9SPhilipp Neuser * 23386e0f1b9SPhilipp Neuser * @author Philipp Neuser <pneuser@physik.fu-berlin.de> 23486e0f1b9SPhilipp Neuser * @param string $user nick of the user to be changed 23586e0f1b9SPhilipp Neuser * @param array $changes array of field/value pairs to be changed (password will be clear text) 23686e0f1b9SPhilipp Neuser * @return bool 23786e0f1b9SPhilipp Neuser */ 23886e0f1b9SPhilipp Neuser public function modifyUser($user, $changes) { 23986e0f1b9SPhilipp Neuser if(is_null($this->chained_auth)) { 240*32fe206aSeinhirn msg("authorisation method does not allow modifying of user data", -1); 24186e0f1b9SPhilipp Neuser return false; 242*32fe206aSeinhirn } else { 24386e0f1b9SPhilipp Neuser //please note: users will be modified in the module, to which the 24486e0f1b9SPhilipp Neuser //current user is logged into 24586e0f1b9SPhilipp Neuser if( $this->canDo('modLogin') && $this->canDo('modPass') && 24686e0f1b9SPhilipp Neuser $this->canDo('modName') && $this->canDo('modMail') && 24786e0f1b9SPhilipp Neuser $this->canDo('modGroups')){ 24886e0f1b9SPhilipp Neuser return $this->chained_auth->createUser($user, $changes); 24986e0f1b9SPhilipp Neuser } else { 250*32fe206aSeinhirn msg("authorisation method does not allow modifying of user data", -1); 25186e0f1b9SPhilipp Neuser return false; 25286e0f1b9SPhilipp Neuser } 25386e0f1b9SPhilipp Neuser } 25486e0f1b9SPhilipp Neuser 25586e0f1b9SPhilipp Neuser } 25686e0f1b9SPhilipp Neuser 25786e0f1b9SPhilipp Neuser /** 25886e0f1b9SPhilipp Neuser * Forwards the result of the auth plugin of the logged in user or 25986e0f1b9SPhilipp Neuser * returns false 26086e0f1b9SPhilipp Neuser * 26186e0f1b9SPhilipp Neuser * @author Philipp Neuser <pneuser@physik.fu-berlin.de> 26286e0f1b9SPhilipp Neuser * @param array $users 26386e0f1b9SPhilipp Neuser * @return int number of users deleted 26486e0f1b9SPhilipp Neuser */ 26586e0f1b9SPhilipp Neuser public function deleteUsers($users) { 26686e0f1b9SPhilipp Neuser if(is_null($this->chained_auth)){ 267*32fe206aSeinhirn msg("authorisation method does not allow deleting of users", -1); 26886e0f1b9SPhilipp Neuser return false; 269*32fe206aSeinhirn } else { 27086e0f1b9SPhilipp Neuser //please note: users will be added to the module, to which the 27186e0f1b9SPhilipp Neuser //current user is logged into 27286e0f1b9SPhilipp Neuser if($this->canDo('delUser')){ 27386e0f1b9SPhilipp Neuser return $this->chained_auth->createUser($users); 27486e0f1b9SPhilipp Neuser }else{ 27586e0f1b9SPhilipp Neuser msg("authorisation method does not allow deleting of users", -1); 27686e0f1b9SPhilipp Neuser return false; 27786e0f1b9SPhilipp Neuser } 27886e0f1b9SPhilipp Neuser } 27986e0f1b9SPhilipp Neuser } 28086e0f1b9SPhilipp Neuser 28186e0f1b9SPhilipp Neuser /** 28286e0f1b9SPhilipp Neuser * Forwards the result of the auth plugin of the logged in user or 28386e0f1b9SPhilipp Neuser * returns 0 28486e0f1b9SPhilipp Neuser * 28586e0f1b9SPhilipp Neuser * @author Philipp Neuser <pneuser@physik.fu-berlin.de> 28686e0f1b9SPhilipp Neuser * @param array $filter array of field/pattern pairs, empty array for no filter 28786e0f1b9SPhilipp Neuser * @return int 28886e0f1b9SPhilipp Neuser */ 28986e0f1b9SPhilipp Neuser public function getUserCount($filter = array()) { 29086e0f1b9SPhilipp Neuser if(is_null($this->chained_auth)){ 291*32fe206aSeinhirn msg("authorisation method does not provide user counts", -1); 29286e0f1b9SPhilipp Neuser return 0; 293*32fe206aSeinhirn } else { 29486e0f1b9SPhilipp Neuser //please note: users will be counted in the module, to which the 29586e0f1b9SPhilipp Neuser //current user is logged into 29686e0f1b9SPhilipp Neuser if($this->canDo('getUserCount')){ 29786e0f1b9SPhilipp Neuser return $this->chained_auth->getUserCount($filter); 29886e0f1b9SPhilipp Neuser } else { 29986e0f1b9SPhilipp Neuser msg("authorisation method does not provide user counts", -1); 30086e0f1b9SPhilipp Neuser return 0; 30186e0f1b9SPhilipp Neuser } 30286e0f1b9SPhilipp Neuser } 30386e0f1b9SPhilipp Neuser } 30486e0f1b9SPhilipp Neuser 30586e0f1b9SPhilipp Neuser /** 30686e0f1b9SPhilipp Neuser * Forwards the result of the auth plugin of the logged in user or 30786e0f1b9SPhilipp Neuser * returns empty array 30886e0f1b9SPhilipp Neuser * 30986e0f1b9SPhilipp Neuser * @author Philipp Neuser <pneuser@physik.fu-berlin.de> 31086e0f1b9SPhilipp Neuser * @param int $start index of first user to be returned 31186e0f1b9SPhilipp Neuser * @param int $limit max number of users to be returned 31286e0f1b9SPhilipp Neuser * @param array $filter array of field/pattern pairs, null for no filter 31386e0f1b9SPhilipp Neuser * @return array list of userinfo (refer getUserData for internal userinfo details) 31486e0f1b9SPhilipp Neuser */ 31586e0f1b9SPhilipp Neuser public function retrieveUsers($start = 0, $limit = -1, $filter = null) { 31686e0f1b9SPhilipp Neuser if(is_null($this->chained_auth)) { 317*32fe206aSeinhirn msg("authorisation method does not support mass retrievals", -1); 31886e0f1b9SPhilipp Neuser return array(); 319*32fe206aSeinhirn } else { 32086e0f1b9SPhilipp Neuser //please note: users will be retrieved from the module, to which the 32186e0f1b9SPhilipp Neuser //current user is logged into 32286e0f1b9SPhilipp Neuser if($this->canDo('getUsers')){ 32386e0f1b9SPhilipp Neuser return $this->chained_auth->retrieveUsers($start, $limit, $filter); 32486e0f1b9SPhilipp Neuser } else { 32586e0f1b9SPhilipp Neuser msg("authorisation method does not support mass retrievals", -1); 32686e0f1b9SPhilipp Neuser return array(); 32786e0f1b9SPhilipp Neuser } 32886e0f1b9SPhilipp Neuser } 32986e0f1b9SPhilipp Neuser } 33086e0f1b9SPhilipp Neuser 33186e0f1b9SPhilipp Neuser /** 33286e0f1b9SPhilipp Neuser * Forwards the result of the auth plugin of the logged in user or 33386e0f1b9SPhilipp Neuser * returns false 33486e0f1b9SPhilipp Neuser * 33586e0f1b9SPhilipp Neuser * @author Philipp Neuser <pneuser@physik.fu-berlin.de> 33686e0f1b9SPhilipp Neuser * @param string $group 33786e0f1b9SPhilipp Neuser * @return bool 33886e0f1b9SPhilipp Neuser */ 33986e0f1b9SPhilipp Neuser public function addGroup($group) { 34086e0f1b9SPhilipp Neuser if(is_null($this->chained_auth)){ 341*32fe206aSeinhirn msg("authorisation method does not support independent group creation", -1); 34286e0f1b9SPhilipp Neuser return false; 343*32fe206aSeinhirn } else { 34486e0f1b9SPhilipp Neuser //please note: users will be added to the module, to which the 34586e0f1b9SPhilipp Neuser //current user is logged into 34686e0f1b9SPhilipp Neuser if($this->canDo('addGroup')) { 34786e0f1b9SPhilipp Neuser return $this->chained_auth->addGroup($group); 34886e0f1b9SPhilipp Neuser } else { 349*32fe206aSeinhirn msg("authorisation method does not support independent group creation", -1); 35086e0f1b9SPhilipp Neuser return false; 35186e0f1b9SPhilipp Neuser } 35286e0f1b9SPhilipp Neuser } 35386e0f1b9SPhilipp Neuser } 35486e0f1b9SPhilipp Neuser 35586e0f1b9SPhilipp Neuser /** 35686e0f1b9SPhilipp Neuser * Forwards the result of the auth plugin of the logged in user or 35786e0f1b9SPhilipp Neuser * returns empty array 35886e0f1b9SPhilipp Neuser * 35986e0f1b9SPhilipp Neuser * @author Philipp Neuser <pneuser@physik.fu-berlin.de> 36086e0f1b9SPhilipp Neuser * @param int $start 36186e0f1b9SPhilipp Neuser * @param int $limit 36286e0f1b9SPhilipp Neuser * @return array 36386e0f1b9SPhilipp Neuser */ 36486e0f1b9SPhilipp Neuser public function retrieveGroups($start = 0, $limit = 0) { 36586e0f1b9SPhilipp Neuser if(is_null($this->chained_auth)){ 366*32fe206aSeinhirn msg("authorisation method does not support group list retrieval", -1); 36786e0f1b9SPhilipp Neuser return array(); 368*32fe206aSeinhirn } else { 36986e0f1b9SPhilipp Neuser //please note: users will be retrieved from the module, to which the 37086e0f1b9SPhilipp Neuser //current user is logged into 37186e0f1b9SPhilipp Neuser if($this->canDo('getGroups')){ 37286e0f1b9SPhilipp Neuser return $this->chained_auth->retrieveGroups($start,$limit); 37386e0f1b9SPhilipp Neuser }else{ 374*32fe206aSeinhirn msg("authorisation method does not support group list retrieval", -1); 37586e0f1b9SPhilipp Neuser return array(); 37686e0f1b9SPhilipp Neuser } 37786e0f1b9SPhilipp Neuser } 37886e0f1b9SPhilipp Neuser } 37986e0f1b9SPhilipp Neuser 38086e0f1b9SPhilipp Neuser /** 38186e0f1b9SPhilipp Neuser * Forwards the result of the auth plugin of the logged in user or 38286e0f1b9SPhilipp Neuser * returns true 38386e0f1b9SPhilipp Neuser * 38486e0f1b9SPhilipp Neuser * @return bool 38586e0f1b9SPhilipp Neuser */ 38686e0f1b9SPhilipp Neuser public function isCaseSensitive() { 38786e0f1b9SPhilipp Neuser if(is_null($this->chained_auth)) 38886e0f1b9SPhilipp Neuser return true; 38986e0f1b9SPhilipp Neuser else 39086e0f1b9SPhilipp Neuser return $this->chained_auth->isCaseSensitive(); 39186e0f1b9SPhilipp Neuser } 39286e0f1b9SPhilipp Neuser 39386e0f1b9SPhilipp Neuser /** 39486e0f1b9SPhilipp Neuser * Sanitize a given username [OPTIONAL] 39586e0f1b9SPhilipp Neuser * Forwards the result of the auth plugin of the logged in user or 39686e0f1b9SPhilipp Neuser * returns false 39786e0f1b9SPhilipp Neuser * 39886e0f1b9SPhilipp Neuser * 39986e0f1b9SPhilipp Neuser * @author Philipp Neuser <pneuser@physik.fu-berlin.de> 40086e0f1b9SPhilipp Neuser * @param string $user username 40186e0f1b9SPhilipp Neuser * @return string the cleaned username 40286e0f1b9SPhilipp Neuser */ 40386e0f1b9SPhilipp Neuser public function cleanUser($user) { 40486e0f1b9SPhilipp Neuser //print_r($this->chained_auth); 40586e0f1b9SPhilipp Neuser if(is_null($this->chained_auth)) 40686e0f1b9SPhilipp Neuser return $user; 40786e0f1b9SPhilipp Neuser else 40886e0f1b9SPhilipp Neuser return $this->chained_auth->cleanUser($user); 40986e0f1b9SPhilipp Neuser } 41086e0f1b9SPhilipp Neuser 41186e0f1b9SPhilipp Neuser /** 41286e0f1b9SPhilipp Neuser * Sanitize a given groupname [OPTIONAL] 41386e0f1b9SPhilipp Neuser * Forwards the result of the auth plugin of the logged in user or 41486e0f1b9SPhilipp Neuser * returns false 41586e0f1b9SPhilipp Neuser * 41686e0f1b9SPhilipp Neuser * @author Philipp Neuser <pneuser@physik.fu-berlin.de> 41786e0f1b9SPhilipp Neuser * @param string $group groupname 41886e0f1b9SPhilipp Neuser * @return string the cleaned groupname 41986e0f1b9SPhilipp Neuser */ 42086e0f1b9SPhilipp Neuser public function cleanGroup($group) { 421*32fe206aSeinhirn if(is_null($this->chained_auth)) { 42286e0f1b9SPhilipp Neuser return $group; 423*32fe206aSeinhirn } else { 42486e0f1b9SPhilipp Neuser return $this->chained_auth->cleanGroup($group); 42586e0f1b9SPhilipp Neuser } 426*32fe206aSeinhirn } 42786e0f1b9SPhilipp Neuser 42886e0f1b9SPhilipp Neuser 42986e0f1b9SPhilipp Neuser public function useSessionCache($user) { 43086e0f1b9SPhilipp Neuser global $conf; 43186e0f1b9SPhilipp Neuser if(is_null($this->chained_auth)) 432*32fe206aSeinhirn return ($_SESSION[DOKU_COOKIE]['auth']['time'] >= @filemtime($conf['cachedir'].'/sessionpurge')); 43386e0f1b9SPhilipp Neuser else 43486e0f1b9SPhilipp Neuser return $this->chained_auth->useSessionCache($user); 43586e0f1b9SPhilipp Neuser } 43686e0f1b9SPhilipp Neuser} 437