diff options
author | Andreas Gohr <andi@splitbrain.org> | 2012-10-06 10:46:10 +0200 |
---|---|---|
committer | Andreas Gohr <andi@splitbrain.org> | 2012-10-06 10:46:10 +0200 |
commit | 93a7873eb0646b5712d75b031cd8b8b143968ba2 (patch) | |
tree | a97bf3309c75947475a42a73f23727f7d2642677 /inc/auth.php | |
parent | 2ca4ac4d5e2214a945489b6aa66c9542b3ee2e4a (diff) | |
parent | f4476bd9b5badd36cd0617d76538e47d9649986b (diff) | |
download | rpg-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 'inc/auth.php')
-rw-r--r-- | inc/auth.php | 42 |
1 files changed, 20 insertions, 22 deletions
diff --git a/inc/auth.php b/inc/auth.php index 99adfa791..25b9e4632 100644 --- a/inc/auth.php +++ b/inc/auth.php @@ -34,38 +34,34 @@ define('AUTH_ADMIN', 255); */ function auth_setup() { global $conf; - /* @var auth_basic $auth */ + /* @var DokuWiki_Auth_Plugin $auth */ global $auth; /* @var Input $INPUT */ global $INPUT; global $AUTH_ACL; global $lang; + global $config_cascade; + global $plugin_controller; $AUTH_ACL = array(); if(!$conf['useacl']) return false; - // load the the backend auth functions and instantiate the auth object XXX - if(@file_exists(DOKU_INC.'inc/auth/'.$conf['authtype'].'.class.php')) { - require_once(DOKU_INC.'inc/auth/basic.class.php'); - require_once(DOKU_INC.'inc/auth/'.$conf['authtype'].'.class.php'); - - $auth_class = "auth_".$conf['authtype']; - if(class_exists($auth_class)) { - $auth = new $auth_class(); - if($auth->success == false) { - // degrade to unauthenticated user - unset($auth); - auth_logoff(); - msg($lang['authtempfail'], -1); - } - } else { - nice_die($lang['authmodfailed']); - } - } else { - nice_die($lang['authmodfailed']); + // try to load auth backend from plugins + foreach ($plugin_controller->getList('auth') as $plugin) { + if ($conf['authtype'] === $plugin) { + $auth = $plugin_controller->load('auth', $plugin); + break; + } } - if(!isset($auth) || !$auth) return false; + if(!$auth) return false; + + if ($auth && $auth->success == false) { + // degrade to unauthenticated user + unset($auth); + auth_logoff(); + msg($lang['authtempfail'], -1); + } // do the login either by cookie or provided credentials XXX $INPUT->set('http_credentials', false); @@ -91,7 +87,9 @@ function auth_setup() { } // apply cleaning - $INPUT->set('u', $auth->cleanUser($INPUT->str('u'))); + if (true === $auth->success) { + $_REQUEST['u'] = $auth->cleanUser($_REQUEST['u']); + } if($INPUT->str('authtok')) { // when an authentication token is given, trust the session |