コード例 #1
0
ファイル: auth.php プロジェクト: jankowa/kolab-octo-dokuwiki
 /**
  * Constructor
  */
 public function __construct()
 {
     parent::__construct();
     global $INPUT;
     // ldap extension is needed
     if (!function_exists('ldap_connect')) {
         $this->_debug("LDAP err: PHP LDAP extension not found.", -1, __LINE__, __FILE__);
         $this->success = false;
         return;
     }
     parse_str(base64_decode(str_pad(strrev($INPUT->get->str('kolab_auth')), strlen($INPUT->get->str('kolab_auth')) % 4, '=', STR_PAD_RIGHT)), $request);
     $postdata = http_build_query($request, '', '&');
     $postdata .= '&hmac=' . hash_hmac('sha256', $postdata, $this->getConf('kolab_secret'));
     $context = stream_context_create(array('http' => array('method' => 'POST', 'header' => "Content-type: application/x-www-form-urlencoded\r\n" . "Content-Length: " . strlen($postdata) . "\r\n" . "Cookie: " . $request['cname'] . '=' . $request['session'] . "\r\n", 'content' => $postdata)));
     $res = file_get_contents($this->getConf('kolab_server') . '?_action=dokuwikisso', false, $context);
     $auth = @json_decode($res, true);
     if ($auth['user'] && $auth['pass']) {
         $login = $auth['user'];
         $password = $auth['pass'];
     }
     $INPUT->set('u', $login);
     $INPUT->set('p', $password);
     // Add the capabilities to change the password
     $this->cando['modPass'] = $this->getConf('modPass');
     // kolab auth
 }
コード例 #2
0
 public function __construct()
 {
     parent::__construct();
     // check pwauth executable
     $this->pwauth_path = $this->getConf('pwauth_path');
     $this->passwd_path = $this->getConf('passwd_path');
     $this->shells_path = $this->getConf('shells_path');
     $this->email_domain_name = $this->getConf('email_domain_name');
     if (is_executable($this->pwauth_path)) {
         $this->cando['addUser'] = false;
         $this->cando['delUser'] = false;
         $this->cando['modLogin'] = false;
         $this->cando['modPass'] = false;
         $this->cando['modName'] = false;
         $this->cando['modMail'] = false;
         $this->cando['modGroups'] = false;
         if (is_readable($this->passwd_path)) {
             $this->cando['getUsers'] = true;
             $this->cando['getUserCount'] = true;
         } else {
             $this->cando['getUsers'] = false;
             $this->cando['getUserCount'] = false;
         }
         $this->cando['getGroups'] = false;
         $this->cando['external'] = false;
         $this->cando['logout'] = true;
         $this->success = true;
     } else {
         $this->success = false;
         echo "pwauth not found!";
     }
 }
コード例 #3
0
ファイル: auth.php プロジェクト: numas/dokuwiki
 /**
  * Constructor
  */
 public function __construct()
 {
     global $INPUT;
     parent::__construct();
     // ldap extension is needed
     if (!function_exists('ldap_connect')) {
         $this->_debug("LDAP err: PHP LDAP extension not found.", -1, __LINE__, __FILE__);
         $this->success = false;
         return;
     }
     // Prepare SSO
     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']);
         }
         // 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');
             }
         }
     }
     // Add the capabilities to change the password
     $this->cando['modPass'] = $this->getConf('modPass');
 }
コード例 #4
0
ファイル: auth.php プロジェクト: spoonysonny/dokuwiki-ucenter
 /**
  * Constructor
  *
  * checks if the mysql interface is available, otherwise it will
  * set the variable $success of the basis class to false
  *
  * @author Matthias Grimm <*****@*****.**>
  */
 public function __construct()
 {
     parent::__construct();
     if (!function_exists('uc_authcode')) {
         $this->_debug("Cannot find UC client API.", -1, __LINE__, __FILE__);
         $this->success = false;
         return;
     }
     if (UC_CHARSET != 'utf-8') {
         $this->cnf['charset'] = 'utf-8';
     }
     if (!isset($this->cnf['sync'])) {
         $this->cnf['sync'] = true;
     }
     if (!isset($this->cnf['cookie'])) {
         $this->cnf['cookie'] = 'dokuwiki_uc_auth';
     }
     // must forward clear pass.
     $this->cnf['forwardClearPass'] = 1;
     $this->cando['addUser'] = true;
     $this->cando['delUser'] = true;
     $this->cando['modLogin'] = false;
     $this->cando['modPass'] = false;
     $this->cando['modName'] = true;
     $this->cando['modMail'] = true;
     $this->cando['modGroups'] = false;
     $this->cando['getUsers'] = true;
     $this->cando['getUserCount'] = false;
     $this->cando['getGroups'] = false;
     $this->cando['external'] = $this->cnf['sync'];
     $this->cando['logoff'] = true;
 }
コード例 #5
0
 /**
  * Constructor.
  */
 public function __construct()
 {
     parent::__construct();
     // Plugin capabilities
     $this->cando['logout'] = true;
     $this->success = true;
 }
コード例 #6
0
ファイル: auth.php プロジェクト: sploadie/authldaplocal
 /**
  * Constructor
  */
 public function __construct()
 {
     parent::__construct();
     global $config_cascade;
     if (!@is_readable($config_cascade['plainauth.users']['default'])) {
         $this->success = false;
     } else {
         if (@is_writable($config_cascade['plainauth.users']['default'])) {
             $this->cando['addUser'] = true;
             $this->cando['delUser'] = true;
             $this->cando['modLogin'] = true;
             $this->cando['modGroups'] = true;
         }
         $this->cando['getUsers'] = true;
         $this->cando['getGroups'] = true;
         $this->cando['getUserCount'] = true;
         $this->cando['logout'] = true;
     }
     // ldap extension is needed
     if (!function_exists('ldap_connect')) {
         $this->_debug("LDAP err: PHP LDAP extension not found.", -1, __LINE__, __FILE__);
         $this->success = false;
         return;
     }
 }
コード例 #7
0
ファイル: auth.php プロジェクト: jotttt/ttu-wiki
 /**
  * Constructor
  *
  * checks if the pgsql interface is available, otherwise it will
  * set the variable $success of the basis class to false
  *
  * @author Matthias Grimm <*****@*****.**>
  * @author Andreas Gohr <*****@*****.**>
  */
 public function __construct()
 {
     // we don't want the stuff the MySQL constructor does, but the grandparent might do something
     DokuWiki_Auth_Plugin::__construct();
     if (!function_exists('pg_connect')) {
         $this->_debug("PgSQL err: PHP Postgres extension not found.", -1, __LINE__, __FILE__);
         $this->success = false;
         return;
     }
     $this->loadConfig();
     // set capabilities based upon config strings set
     if (empty($this->conf['user']) || empty($this->conf['password']) || empty($this->conf['database'])) {
         $this->_debug("PgSQL err: insufficient configuration.", -1, __LINE__, __FILE__);
         $this->success = false;
         return;
     }
     $this->cando['addUser'] = $this->_chkcnf(array('getUserInfo', 'getGroups', 'addUser', 'getUserID', 'getGroupID', 'addGroup', 'addUserGroup'));
     $this->cando['delUser'] = $this->_chkcnf(array('getUserID', 'delUser', 'delUserRefs'));
     $this->cando['modLogin'] = $this->_chkcnf(array('getUserID', 'updateUser', 'UpdateTarget'));
     $this->cando['modPass'] = $this->cando['modLogin'];
     $this->cando['modName'] = $this->cando['modLogin'];
     $this->cando['modMail'] = $this->cando['modLogin'];
     $this->cando['modGroups'] = $this->_chkcnf(array('getUserID', 'getGroups', 'getGroupID', 'addGroup', 'addUserGroup', 'delGroup', 'getGroupID', 'delUserGroup'));
     /* getGroups is not yet supported
        $this->cando['getGroups']    = $this->_chkcnf(array('getGroups',
        'getGroupID')); */
     $this->cando['getUsers'] = $this->_chkcnf(array('getUsers', 'getUserInfo', 'getGroups'));
     $this->cando['getUserCount'] = $this->_chkcnf(array('getUsers'));
 }
コード例 #8
0
ファイル: auth.php プロジェクト: janzoner/dokuwiki
 /**
  * Constructor
  */
 public function __construct()
 {
     parent::__construct();
     // ldap extension is needed
     if (!function_exists('ldap_connect')) {
         $this->_debug("LDAP err: PHP LDAP extension not found.", -1, __LINE__, __FILE__);
         $this->success = false;
         return;
     }
     // Add the capabilities to change the password
     $this->cando['modPass'] = $this->getConf('modPass');
 }
コード例 #9
0
ファイル: auth.php プロジェクト: ngharaibeh/Methodikos
 /**
  * Constructor
  */
 public function __construct()
 {
     parent::__construct();
     // ldap extension is needed
     if (!function_exists('ldap_connect')) {
         $this->_debug("LDAP err: PHP LDAP extension not found.", -1, __LINE__, __FILE__);
         $this->success = false;
         return;
     }
     // auth_ldap currently just handles authentication, so no
     // capabilities are set
 }
コード例 #10
0
ファイル: auth.php プロジェクト: xenim/django-external-auth
 /**
  * Constructor.
  */
 public function __construct()
 {
     parent::__construct();
     // for compatibility
     $this->cando['getGroups'] = true;
     // can a list of available groups be retrieved?
     $this->cando['external'] = true;
     // does the module do external auth checking?
     $this->cando['logout'] = false;
     // can the user logout again? (eg. not possible with HTTP auth)
     $this->success = true;
 }
コード例 #11
0
ファイル: auth.php プロジェクト: msims04/eveseat-addon-auth
 /**
  * Constructor.
  */
 public function __construct()
 {
     parent::__construct();
     $this->cando['addUser'] = false;
     $this->cando['delUser'] = false;
     $this->cando['modLogin'] = false;
     $this->cando['modPass'] = false;
     $this->cando['modName'] = false;
     $this->cando['modMail'] = false;
     $this->cando['modGroups'] = false;
     $this->cando['getUsers'] = false;
     $this->cando['getUserCount'] = false;
     $this->cando['getGroups'] = false;
     $this->cando['external'] = true;
     $this->cando['logout'] = true;
     $this->success = true;
 }
コード例 #12
0
 /**
  * Builds the chain, initializes current and usermanager plugins.
  */
 public function __construct()
 {
     parent::__construct();
     // initialize auth plugin for the current user if set
     $currentPluginName = $this->getCurrentPluginName();
     if (!empty($currentPluginName)) {
         $this->currentPlugin = plugin_load('auth', $currentPluginName);
         if (empty($this->currentPlugin) || !$this->currentPlugin->success) {
             $this->msg(-1, 'plugin_not_initialized', array(':plugin:' => $currentPluginName));
             $this->success = false;
         }
     }
     // initialize the chain
     $this->plugins = array();
     $plugins = $this->getConf('authtypes');
     if (!empty($plugins)) {
         $usermanagerPlugin = $this->getConf('usermanager_authtype');
         foreach (explode(':', $plugins) as $pluginName) {
             /** @var DokuWiki_Auth_Plugin $plugin */
             $plugin = plugin_load('auth', $pluginName);
             if (empty($plugin) || !$plugin->success) {
                 $this->msg(-1, 'plugin_not_initialized', array(':plugin:' => $pluginName));
                 continue;
             }
             // add the plugin to the chain
             $this->plugins[] = $plugin;
             // set chain capabilities
             foreach (array('external', 'getGroups') as $capability) {
                 if ($plugin->canDo($capability)) {
                     $this->cando[$capability] = true;
                 }
             }
             // set usermanager plugin capabilities
             if (!empty($usermanagerPlugin) && $pluginName == $usermanagerPlugin) {
                 $this->usermanagerPlugin = $plugin;
                 foreach ($this->cando as $key => &$value) {
                     $value = $value || $plugin->canDo($key);
                 }
             }
         }
     }
     if (empty($this->plugins)) {
         $this->success = false;
     }
 }
コード例 #13
0
ファイル: auth.php プロジェクト: splitbrain/dokuwiki
 /**
  * Constructor.
  */
 public function __construct()
 {
     parent::__construct();
     // for compatibility
     if (!class_exists('PDO')) {
         $this->_debug('PDO extension for PHP not found.', -1, __LINE__);
         $this->success = false;
         return;
     }
     if (!$this->getConf('dsn')) {
         $this->_debug('No DSN specified', -1, __LINE__);
         $this->success = false;
         return;
     }
     try {
         $this->pdo = new PDO($this->getConf('dsn'), $this->getConf('user'), conf_decodeString($this->getConf('pass')), array(PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC, PDO::ATTR_EMULATE_PREPARES => true, PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION));
     } catch (PDOException $e) {
         $this->_debug($e);
         msg($this->getLang('connectfail'), -1);
         $this->success = false;
         return;
     }
     // can Users be created?
     $this->cando['addUser'] = $this->_chkcnf(array('select-user', 'select-user-groups', 'select-groups', 'insert-user', 'insert-group', 'join-group'));
     // can Users be deleted?
     $this->cando['delUser'] = $this->_chkcnf(array('select-user', 'select-user-groups', 'select-groups', 'leave-group', 'delete-user'));
     // can login names be changed?
     $this->cando['modLogin'] = $this->_chkcnf(array('select-user', 'select-user-groups', 'update-user-login'));
     // can passwords be changed?
     $this->cando['modPass'] = $this->_chkcnf(array('select-user', 'select-user-groups', 'update-user-pass'));
     // can real names be changed?
     $this->cando['modName'] = $this->_chkcnf(array('select-user', 'select-user-groups', 'update-user-info:name'));
     // can real email be changed?
     $this->cando['modMail'] = $this->_chkcnf(array('select-user', 'select-user-groups', 'update-user-info:mail'));
     // can groups be changed?
     $this->cando['modGroups'] = $this->_chkcnf(array('select-user', 'select-user-groups', 'select-groups', 'leave-group', 'join-group', 'insert-group'));
     // can a filtered list of users be retrieved?
     $this->cando['getUsers'] = $this->_chkcnf(array('list-users'));
     // can the number of users be retrieved?
     $this->cando['getUserCount'] = $this->_chkcnf(array('count-users'));
     // can a list of available groups be retrieved?
     $this->cando['getGroups'] = $this->_chkcnf(array('select-groups'));
     $this->success = true;
 }
コード例 #14
0
ファイル: auth.php プロジェクト: kevinlovesing/dokuwiki
 /**
  * Constructor
  */
 public function __construct()
 {
     global $INPUT;
     parent::__construct();
     // we load the config early to modify it a bit here
     $this->loadConfig();
     // additional information fields
     if (isset($this->conf['additional'])) {
         $this->conf['additional'] = str_replace(' ', '', $this->conf['additional']);
         $this->conf['additional'] = explode(',', $this->conf['additional']);
     } else {
         $this->conf['additional'] = array();
     }
     // ldap extension is needed
     if (!function_exists('ldap_connect')) {
         if ($this->conf['debug']) {
             msg("AD Auth: PHP LDAP extension not found.", -1);
         }
         $this->success = false;
         return;
     }
     // Prepare SSO
     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']);
         }
         // 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');
             }
         }
     }
     // other can do's are changed in $this->_loadServerConfig() base on domain setup
     $this->cando['modName'] = true;
     $this->cando['modMail'] = true;
     $this->cando['getUserCount'] = true;
 }
コード例 #15
0
ファイル: auth.php プロジェクト: omusico/isle-web-framework
 /**
  * Constructor
  *
  * Carry out sanity checks to ensure the object is
  * able to operate. Set capabilities.
  *
  * @author  Christopher Smith <*****@*****.**>
  */
 public function __construct()
 {
     parent::__construct();
     global $config_cascade;
     if (!@is_readable($config_cascade['plainauth.users']['default'])) {
         $this->success = false;
     } else {
         if (@is_writable($config_cascade['plainauth.users']['default'])) {
             $this->cando['addUser'] = true;
             $this->cando['delUser'] = true;
             $this->cando['modLogin'] = true;
             $this->cando['modPass'] = true;
             $this->cando['modName'] = true;
             $this->cando['modMail'] = true;
             $this->cando['modGroups'] = true;
         }
         $this->cando['getUsers'] = true;
         $this->cando['getUserCount'] = true;
     }
 }
コード例 #16
0
 /**
  * Constructor
  *
  * checks if the mysql interface is available, otherwise it will
  * set the variable $success of the basis class to false
  *
  * @author Matthias Grimm <*****@*****.**>
  */
 public function __construct()
 {
     parent::__construct();
     if (!function_exists('mysql_connect')) {
         $this->_debug("MySQL err: PHP MySQL extension not found.", -1, __LINE__, __FILE__);
         $this->success = false;
         return;
     }
     // set capabilities based upon config strings set
     if (!$this->getConf('server') || !$this->getConf('user') || !$this->getConf('database')) {
         $this->_debug("MySQL err: insufficient configuration.", -1, __LINE__, __FILE__);
         $this->success = false;
         return;
     }
     $this->cando['addUser'] = $this->_chkcnf(array('getUserInfo', 'getGroups', 'addUser', 'getUserID', 'getGroupID', 'addGroup', 'addUserGroup'), true);
     $this->cando['delUser'] = $this->_chkcnf(array('getUserID', 'delUser', 'delUserRefs'), true);
     $this->cando['modLogin'] = $this->_chkcnf(array('getUserID', 'updateUser', 'UpdateTarget'), true);
     $this->cando['modPass'] = $this->cando['modLogin'];
     $this->cando['modName'] = $this->cando['modLogin'];
     $this->cando['modMail'] = $this->cando['modLogin'];
     $this->cando['modGroups'] = $this->_chkcnf(array('getUserID', 'getGroups', 'getGroupID', 'addGroup', 'addUserGroup', 'delGroup', 'getGroupID', 'delUserGroup'), true);
     /* getGroups is not yet supported
        $this->cando['getGroups']    = $this->_chkcnf(array('getGroups',
        'getGroupID'),false); */
     $this->cando['getUsers'] = $this->_chkcnf(array('getUsers', 'getUserInfo', 'getGroups'), false);
     $this->cando['getUserCount'] = $this->_chkcnf(array('getUsers'), false);
     if ($this->getConf('debug') >= 2) {
         $candoDebug = '';
         foreach ($this->cando as $cd => $value) {
             if ($value) {
                 $value = 'yes';
             } else {
                 $value = 'no';
             }
             $candoDebug .= $cd . ": " . $value . " | ";
         }
         $this->_debug("authmysql cando: " . $candoDebug, 0, __LINE__, __FILE__);
     }
 }
コード例 #17
0
 /**
  * Constructor.
  */
 public function __construct()
 {
     parent::__construct();
     // for compatibility
     $this->cando['addUser'] = false;
     // can Users be created?
     $this->cando['delUser'] = false;
     // can Users be deleted?
     $this->cando['modLogin'] = false;
     // can login names be changed?
     $this->cando['modPass'] = false;
     // can passwords be changed?
     $this->cando['modName'] = false;
     // can real names be changed?
     $this->cando['modMail'] = false;
     // can emails be changed?
     $this->cando['modGroups'] = false;
     // can groups be changed?
     $this->cando['getUsers'] = false;
     // can a (filtered) list of users be retrieved?
     $this->cando['getUserCount'] = false;
     // can the number of users be retrieved?
     $this->cando['getGroups'] = false;
     // can a list of available groups be retrieved?
     $this->cando['logout'] = true;
     // can the user logout again? (eg. not possible with HTTP auth)
     $this->cando['external'] = true;
     // does the module do external auth checking?
     // $this->loadConfig(); // deprecated seit 2012
     $this->ssourl = $this->getConf('ssourl');
     $ov = $this->getConf('ov');
     if (!empty($ov)) {
         $this->ssourl = $this->addUrlParams($this->ssourl, array("ov" => $ov));
     }
     $this->data = array();
     $this->triedsilent = isset($_SESSION[DOKU_COOKIE]['auth']['hiorg']['triedsilent']) && $_SESSION[DOKU_COOKIE]['auth']['hiorg']['triedsilent'] == true;
     $this->success = true;
 }
コード例 #18
0
ファイル: auth.php プロジェクト: amulheirn/authphpbb3
 /**
  * Constructor.
  */
 public function __construct()
 {
     global $conf;
     parent::__construct();
     // Set capabilities accordingly
     $this->cando['addUser'] = false;
     // can Users be created?
     $this->cando['delUser'] = false;
     // can Users be deleted?
     $this->cando['modLogin'] = false;
     // can login names be changed?
     $this->cando['modPass'] = false;
     // can passwords be changed?
     $this->cando['modName'] = false;
     // can real names be changed?
     $this->cando['modMail'] = false;
     // can emails be changed?
     $this->cando['modGroups'] = false;
     // can groups be changed?
     $this->cando['getUsers'] = false;
     // can a (filtered) list of users be retrieved?
     $this->cando['getUserCount'] = false;
     // can the number of users be retrieved?
     $this->cando['getGroups'] = true;
     // can a list of available groups be retrieved?
     $this->cando['external'] = true;
     // does the module do external auth checking?
     $this->cando['logout'] = false;
     // can the user logout again?
     //  Load the config
     $this->loadConfig();
     // set and check the config values
     $wikirootpath = realpath(dirname(__FILE__) . "/../../../");
     $phpbb3relpath = $this->getConf("phpbb3rootpath");
     $phpbb3relpath = trim($phpbb3relpath);
     // remove (if exist) spases from start/end of path
     $phpbb3relpath = trim($phpbb3relpath, "/\\");
     // remove (if exist) slashes from start/end of path
     $phpbb3config = $wikirootpath . '/' . $phpbb3relpath . '/config.php';
     if (!$phpbb3config) {
         // Error : $phpbb3config not set
         dbglog("authphpbb3 error: phpbb3config is not set");
         msg("Configuration error. Contact wiki administrator", -1);
         $this->success = false;
         return;
     }
     if (!file_exists($phpbb3config)) {
         // Error: phpbb3 config file not found
         dbglog("authphpbb3 error: phpbb3 config {$phpbb3config} not found");
         msg("Configuration error. Contact wiki administrator", -1);
         $this->success = false;
         return;
     }
     include $phpbb3config;
     $this->phpbb3_dbhost = $dbhost;
     $this->phpbb3_dbname = $dbname;
     $this->phpbb3_dbuser = $dbuser;
     $this->phpbb3_dbpasswd = $dbpasswd;
     $this->phpbb3_table_prefix = $table_prefix;
     foreach (array("phpbb3_dbhost", "phpbb3_dbname", "phpbb3_dbuser", "phpbb3_dbpasswd") as $cfgvar) {
         if (is_null($this->{$cfgvar})) {
             msg("Configuration error. Contact wiki administrator", -1);
             dbglog("authphpbb3 error: phpbb3 config variable {$cfgvar} not set");
             $this->success = false;
             return;
         }
     }
     $this->success = true;
 }
コード例 #19
0
ファイル: auth.php プロジェクト: papillon326/authplaincas
 /**
  * Constructor
  *
  * Carry out sanity checks to ensure the object is
  * able to operate. Set capabilities.
  *
  * @author     Fabian Bircher <*****@*****.**>
  */
 public function __construct()
 {
     parent::__construct();
     global $config_cascade;
     global $conf;
     // allow the preloading to configure other user files
     if (isset($config_cascade['plaincasauth.users']) && isset($config_cascade['plaincasauth.users']['default'])) {
         $this->casuserfile = $config_cascade['plaincasauth.users']['default'];
     } else {
         $this->casuserfile = DOKU_CONF . 'users.auth.plaincas.php';
     }
     $this->localuserfile = $config_cascade['plainauth.users']['default'];
     // check the state of the file with the users and attempt to create it.
     if (!@is_readable($this->casuserfile)) {
         if (!fopen($this->casuserfile, 'w')) {
             msg("plainCAS: The CAS users file could not be opened.", -1);
             $this->success = false;
         } elseif (!@is_readable($this->casuserfile)) {
             $this->success = false;
         } else {
             $this->success = true;
         }
         // die( "bitch!" );
     }
     if ($this->success) {
         // the users are not managable through the wiki
         $this->cando['addUser'] = false;
         $this->cando['delUser'] = true;
         $this->cando['modLogin'] = false;
         //keep this false as CAS name is constant
         $this->cando['modPass'] = false;
         $this->cando['modName'] = false;
         $this->cando['modMail'] = false;
         $this->cando['modGroups'] = false;
         $this->cando['getUsers'] = true;
         $this->cando['getUserCount'] = true;
         $this->cando['external'] = preg_match("#(bot)|(slurp)|(netvibes)#i", $_SERVER['HTTP_USER_AGENT']) ? false : true;
         //Disable CAS redirection for bots/crawlers/readers
         $this->cando['login'] = true;
         $this->cando['logout'] = true;
         $this->cando['logoff'] = true;
         // The default options which need to be set in the settins file.
         $defaults = array('logFile' => NULL, 'cert' => NULL, 'cacert' => NULL, 'debug' => false, 'settings_file' => DOKU_CONF . 'plaincas.settings.php', 'defaultgroup' => $conf['defaultgroup'], 'superuser' => $conf['superuser']);
         $this->_options = (array) $conf['plugin']['authplaincas'] + $defaults;
         // Options are set in the configuration and have a proper default value there.
         $this->_options['server'] = $this->getConf('server');
         $this->_options['rootcas'] = $this->getConf('rootcas');
         $this->_options['port'] = $this->getConf('port');
         $this->_options['samlValidate'] = $this->getConf('samlValidate');
         $this->_options['autologin'] = $this->getConf('autologinout');
         // $this->getConf('autologin');
         $this->_options['caslogout'] = $this->getConf('autologinout');
         // $this->getConf('caslogout');
         $this->_options['handlelogoutrequest'] = $this->getConf('handlelogoutrequest');
         $this->_options['handlelogoutrequestTrustedHosts'] = $this->getConf('handlelogoutrequestTrustedHosts');
         $this->_options['minimalgroups'] = $this->getConf('minimalgroups');
         $this->_options['localusers'] = $this->getConf('localusers');
         // $this->_options['defaultgroup'] = $this->getConf('defaultgroup');
         // $this->_options['superuser'] = $this->getConf('superuser');
         // no local users at the moment
         $this->_options['localusers'] = false;
         if ($this->_options['localusers'] && !@is_readable($this->localuserfile)) {
             msg("plainCAS: The local users file is not readable.", -1);
             $this->success = false;
         }
         if ($this->_getOption("logFile")) {
             phpCAS::setDebug($this->_getOption("logFile"));
         }
         //If $conf['auth']['cas']['logFile'] exist we start phpCAS in debug mode
         $server_version = CAS_VERSION_2_0;
         if ($this->_getOption("samlValidate")) {
             $server_version = SAML_VERSION_1_1;
         }
         phpCAS::client($server_version, $this->_getOption('server'), (int) $this->_getOption('port'), $this->_getOption('rootcas'), true);
         //Note the last argument true, to allow phpCAS to change the session_id so he will be able to destroy the session after a CAS logout request - Enable Single Sign Out
         // curl extension is needed
         if (!function_exists('curl_init')) {
             if ($this->_getOption('debug')) {
                 msg("CAS err: CURL extension not found.", -1, __LINE__, __FILE__);
             }
             $this->success = false;
             return;
         }
         // automatically log the user when there is a cas session opened
         if ($this->_getOption('autologin')) {
             phpCAS::setCacheTimesForAuthRecheck(1);
         } else {
             phpCAS::setCacheTimesForAuthRecheck(-1);
         }
         if ($this->_getOption('cert')) {
             phpCAS::setCasServerCert($this->_getOption('cert'));
         } elseif ($this->_getOption('cacert')) {
             phpCAS::setCasServerCACert($this->_getOption('cacert'));
         } else {
             phpCAS::setNoCasServerValidation();
         }
         if ($this->_getOption('handlelogoutrequest')) {
             phpCAS::handleLogoutRequests(true, $this->_getOption('handlelogoutrequestTrustedHosts'));
         } else {
             phpCAS::handleLogoutRequests(false);
         }
         if (@is_readable($this->_getOption('settings_file'))) {
             include_once $this->_getOption('settings_file');
         } else {
             include_once DOKU_PLUGIN . 'authplaincas/plaincas.settings.php';
         }
     }
     //
 }