diff options
author | Jan Schumann <js@schumann-it.com> | 2012-02-20 19:51:26 +0100 |
---|---|---|
committer | Jan Schumann <js@schumann-it.com> | 2012-02-20 19:51:26 +0100 |
commit | f4476bd9b5badd36cd0617d76538e47d9649986b (patch) | |
tree | 8100a814f4ccc279694f0a77596ce498a6eb4a0c /lib/plugins/config | |
parent | 396b87bebcb14765849b43a259a2b6cf2aff98f3 (diff) | |
download | rpg-f4476bd9b5badd36cd0617d76538e47d9649986b.tar.gz rpg-f4476bd9b5badd36cd0617d76538e47d9649986b.tar.bz2 |
Refactored auth system: All auth methods are now introduced as plugins.
Diffstat (limited to 'lib/plugins/config')
-rw-r--r-- | lib/plugins/config/settings/extra.class.php | 50 |
1 files changed, 40 insertions, 10 deletions
diff --git a/lib/plugins/config/settings/extra.class.php b/lib/plugins/config/settings/extra.class.php index cee3c6b20..f6adf1c18 100644 --- a/lib/plugins/config/settings/extra.class.php +++ b/lib/plugins/config/settings/extra.class.php @@ -45,22 +45,52 @@ if (!class_exists('setting_authtype')) { function initialize($default,$local,$protected) { global $plugin_controller; - // populate $this->_choices with a list of available auth mechanisms - $authtypes = glob(DOKU_INC.'inc/auth/*.class.php'); - $authtypes = preg_replace('#^.*/([^/]*)\.class\.php$#i','$1', $authtypes); - $authtypes = array_diff($authtypes, array('basic')); - // retrive auth types provided by plugins foreach ($plugin_controller->getList('auth') as $plugin) { - $authtypes[] = $plugin; + $this->_choices[] = $plugin; } - $authtypes = array_unique($authtypes); - - $this->_choices = $authtypes; - parent::initialize($default,$local,$protected); } + + function update($input) { + global $plugin_controller; + + // is an update posible? + $mayUpdate = parent::update($input); + + // is it an auth plugin? + if (in_array($input, $plugin_controller->getList('auth'))) { + // reject disabled plugins + if ($plugin_controller->isdisabled($input)) { + $this->_error = true; + msg('Auth type ' . $input . ' is disabled.'); + return false; + } + + // load the plugin + $auth_plugin = $plugin_controller->load('auth', $input); + + // @TODO: throw an error in plugin controller instead of returning null + if (is_null($auth_plugin)) { + $this->_error = true; + msg('Cannot load Auth Plugin "' . $input . '"'); + return false; + } + + // verify proper instanciation (is this really a plugin?) @TODO use instanceof? impement interface? + if (is_object($auth_plugin) && !method_exists($auth_plugin, 'getPluginName')) { + $this->_error = true; + msg('Cannot create Auth Plugin "' . $input . '"'); + return false; + } + } + + msg('Successfully changed auth system. Please re-login.'); + auth_logoff(); + + return true; + } } } |