Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 36 additions & 6 deletions auth.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ class auth_plugin_authsplit extends DokuWiki_Auth_Plugin {
protected $authplugins;
protected $autocreate_users;
protected $debug;
protected $use_fallback;

/**
* Show a debug message
Expand All @@ -39,7 +40,7 @@ public function __construct() {
$this->loadConfig();

/* Load all referenced auth plugins */
foreach (array('primary', 'secondary') as $type) {
foreach (array('primary', 'secondary', 'fallback') as $type) {
$settingName = $type.'_authplugin';
$pluginName = $this->getConf($settingName);
if (!$pluginName) {
Expand Down Expand Up @@ -74,6 +75,14 @@ public function __construct() {
$this->success = false;
return;
}
/* Use fallback auth methode? */
$this->use_fallback = $this->getConf('use_fallback', null);
if ($this->use_fallback === null) {
msg(sprintf($this->getLang('nocfg'), 'use_fallback'), -1);
$this->success = false;
return;
}


/* Of course, to modify login names actually BOTH auth plugins must
support that. However, at this place we just consider the secondary
Expand Down Expand Up @@ -142,15 +151,36 @@ public function checkPass($user, $pass) {
'authsplit:checkPass(): primary auth plugin\'s checkPass() '.
'failed', -1, __LINE__, __FILE__
);
return false;

if ($this->use_fallback) {
$this->_debug(
'authsplit:checkPass(): use fallback auth plugin\'s '.
'checkPass()', -1, __LINE__, __FILE__
);

if (!$this->authplugins['fallback']->checkPass($user, $pass)) {
$this->_debug(
'authsplit:checkPass(): fallback auth plugin\'s checkPass() '.
'failed', -1, __LINE__, __FILE__
);
return false;
} else {
$this->_debug(
'authsplit:checkPass(): fallback auth plugin authenticated the '.
'user successfully.', 1, __LINE__, __FILE__
);
}
}
} else {
$this->_debug(
'authsplit:checkPass(): primary auth plugin authenticated the '.
'user successfully.', 1, __LINE__, __FILE__
);
}
$this->_debug(
'authsplit:checkPass(): primary auth plugin authenticated the '.
'user successfully.', 1, __LINE__, __FILE__
);

/* Then make sure that the secondary auth plugin also knows about the
user. */

return $this->_checkUserOnSecondaryAuthPlugin($user);
}

Expand Down
2 changes: 2 additions & 0 deletions conf/default.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,5 @@
$conf['secondary_authplugin'] = 'authplain';
$conf['autocreate_users'] = 0;
$conf['debug'] = 0;
$conf['use_fallback'] = 0;
$conf['fallback_authplugin'] = 'authplain';
2 changes: 2 additions & 0 deletions conf/metadata.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,5 @@ function initialize($default, $local, $protected) {
$meta['secondary_authplugin'] = array('authtype_nosplit', '_cautionList' => array('plugin____authsplit____secondary_authplugin' => 'danger'));
$meta['autocreate_users'] = array('onoff');
$meta['debug'] = array('onoff');
$meta['fallback_authplugin'] = array('authtype_nosplit', '_cautionList' => array('plugin____authsplit____secondary_authplugin' => 'danger'));
$meta['use_fallback'] = array('onoff');