From a16dd68e698185f207e0bd3cf3b3f22619417519 Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Sat, 21 Jan 2006 19:11:49 +0100 Subject: streamlining auth backends :!: This patch is a start to make all the auth backend mor alike in configuration and to update all backend to the new OO method. This patch changed some config placeholders and thus may break existing configs! Here is a list of the new place holders used in MySQL and LDAP: %{user} - the login name %{group} - a group name %{pass} - the password (cleartext or crypted) %{dgroup} - the default group %{guid} - a group id %{uid} - a user id %{name} - full name of a user %{email} - email of a user %{dn} - DN for a user (LDAP only) The LDAP backend was enhanced a little bit. The default group now is always added to the list of returned groups. A different Server Port can be configured. More changes will follow. darcs-hash:20060121181149-7ad00-79de68aa7f87aef87dcff9dd7afd50adda859289.gz --- inc/auth/plain.php | 120 ----------------------------------------------------- 1 file changed, 120 deletions(-) delete mode 100644 inc/auth/plain.php (limited to 'inc/auth/plain.php') diff --git a/inc/auth/plain.php b/inc/auth/plain.php deleted file mode 100644 index d9569c3fd..000000000 --- a/inc/auth/plain.php +++ /dev/null @@ -1,120 +0,0 @@ - - */ - -// we only accept page ids for auth_plain -if(isset($_REQUEST['u'])) - $_REQUEST['u'] = cleanID($_REQUEST['u']); - -/** - * Check user+password [required auth function] - * - * Checks if the given user exists and the given - * plaintext password is correct - * - * @author Andreas Gohr - * @return bool - */ -function auth_checkPass($user,$pass){ - $users = auth_plain_loadUserData(); - - if(!isset($users[$user])) return false; - - return auth_verifyPassword($pass,$users[$user]['pass']); -} - -/** - * Return user info [required auth function] - * - * Returns info about the given user needs to contain - * at least these fields: - * - * name string full name of the user - * mail string email addres of the user - * grps array list of groups the user is in - * - * @author Andreas Gohr - */ -function auth_getUserData($user){ - static $users = null; - - if($users == null) { - $users = auth_plain_loadUserData(); - } - return $users[$user]; -} - -/** - * Create a new User [required auth function] - * - * Returns false if the user already exists, null when an error - * occured and the cleartext password of the new user if - * everything went well. - * - * The new user HAS TO be added to the default group by this - * function! - * - * @author Andreas Gohr - */ -function auth_createUser($user,$pass,$name,$mail){ - global $conf; - - $users = auth_plain_loadUserData(); - if(isset($users[$user])) return false; - - $userline = join(':',array($user, - auth_cryptPassword($pass), - $name, - $mail, - $conf['defaultgroup'])); - $userline .= "\n"; - $fh = fopen(DOKU_CONF.'users.auth.php','a'); - if($fh){ - fwrite($fh,$userline); - fclose($fh); - return $pass; - } - msg('The users.auth.php file is not writable. Please inform the Wiki-Admin',-1); - return null; -} - -/** - * Load all user data - * - * Used by the plaintext auth functions - * loads the user file into a datastructure - * - * @author Andreas Gohr - */ -function auth_plain_loadUserData(){ - $data = array(); - if(!@file_exists(DOKU_CONF.'users.auth.php')){ - return $data; - } - $lines = file(DOKU_CONF.'users.auth.php'); - foreach($lines as $line){ - $line = preg_replace('/#.*$/','',$line); //ignore comments - $line = trim($line); - if(empty($line)) continue; - - $row = split(":",$line,5); - $groups = split(",",$row[4]); - $data[$row[0]]['pass'] = $row[1]; - $data[$row[0]]['name'] = urldecode($row[2]); - $data[$row[0]]['mail'] = $row[3]; - $data[$row[0]]['grps'] = $groups; - } - return $data; -} - - -//Setup VIM: ex: et ts=2 enc=utf-8 : -- cgit v1.2.3