summaryrefslogtreecommitdiff
path: root/lib/plugins/config
diff options
context:
space:
mode:
authorAndreas Gohr <andi@splitbrain.org>2012-10-06 10:46:10 +0200
committerAndreas Gohr <andi@splitbrain.org>2012-10-06 10:46:10 +0200
commit93a7873eb0646b5712d75b031cd8b8b143968ba2 (patch)
treea97bf3309c75947475a42a73f23727f7d2642677 /lib/plugins/config
parent2ca4ac4d5e2214a945489b6aa66c9542b3ee2e4a (diff)
parentf4476bd9b5badd36cd0617d76538e47d9649986b (diff)
downloadrpg-93a7873eb0646b5712d75b031cd8b8b143968ba2.tar.gz
rpg-93a7873eb0646b5712d75b031cd8b8b143968ba2.tar.bz2
Merge remote-tracking branch 'janschumann/master' into future
This merge fixes all conflicts but is otherwise untested and might break funktionality in the auth system somewhere. It NEEDS MAJOR TESTING! Some refactoring of the auth plugins is still needed: * move to PHP5 style * fix comments * add plugin.info.txt * janschumann/master: Refactored auth system: All auth methods are now introduced as plugins. Bugfix: auth types are now correcty added Setup auth system from plugins Added Auth-Plugin-Prototype to autoload Load auth types from plugins in settings_authtype class Added prototype for Auth-Plugins added plugin type 'auth' Conflicts: inc/auth.php inc/auth/pgsql.class.php inc/init.php inc/load.php lib/plugins/auth.php lib/plugins/authad/auth.php lib/plugins/authldap/auth.php lib/plugins/authmysql/auth.php lib/plugins/authplain/auth.php
Diffstat (limited to 'lib/plugins/config')
-rw-r--r--lib/plugins/config/settings/extra.class.php51
1 files changed, 44 insertions, 7 deletions
diff --git a/lib/plugins/config/settings/extra.class.php b/lib/plugins/config/settings/extra.class.php
index b4e35b1cc..f6adf1c18 100644
--- a/lib/plugins/config/settings/extra.class.php
+++ b/lib/plugins/config/settings/extra.class.php
@@ -43,17 +43,54 @@ if (!class_exists('setting_authtype')) {
class setting_authtype extends setting_multichoice {
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'));
- sort($authtypes);
-
- $this->_choices = $authtypes;
+ // retrive auth types provided by plugins
+ foreach ($plugin_controller->getList('auth') as $plugin) {
+ $this->_choices[] = $plugin;
+ }
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;
+ }
}
}