From 82fd59b6cf8cda9b2c419fb08bbc40a571b36fe8 Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Fri, 3 Feb 2006 16:03:02 +0100 Subject: new way of auth module capability checking This changes the way of how the capabilities of the used auth module are checked as suggested as first option in http://www.freelists.org/archives/dokuwiki/01-2006/msg00267.html The MySQL backend WAS NOT TESTED and probably needs some work. darcs-hash:20060203150302-7ad00-c524cafe20499f32e76ad42b4e68d7c635f6a9e9.gz --- inc/auth/plain.class.php | 75 +++++++++++------------------------------------- 1 file changed, 16 insertions(+), 59 deletions(-) (limited to 'inc/auth/plain.class.php') diff --git a/inc/auth/plain.class.php b/inc/auth/plain.class.php index 373bb2907..2dae8de98 100644 --- a/inc/auth/plain.class.php +++ b/inc/auth/plain.class.php @@ -25,37 +25,28 @@ class auth_plain extends auth_basic { * Constructor * * Carry out sanity checks to ensure the object is - * able to operate. + * able to operate. Set capabilities. * - * Set $this->success to false if checks fail - * * @author Christopher Smith */ function auth_plain() { - if (!@is_readable(AUTH_USERFILE)) $this->success = false; + if (!@is_readable(AUTH_USERFILE)){ + $this->success = false; + }else{ + if(@is_writable(AUTH_USERFILE)){ + $this->cando['addUser'] = true; + $this->cando['delUser'] = true; + $this->cando['modLogin'] = true; + $this->cando['modPass'] = true; + $this->cando['modName'] = true; + $this->cando['modMail'] = true; + $this->cando['modGroups'] = true; + } + $this->cando['getUsers'] = true; + $this->cando['getUserCount'] = true; + } } - /** - * Check if authorisation mechanism supports fn and - * that fn will operate in the current environment - * - * @author Christopher Smith - * @return bool - */ - function canDo($fn) { - - switch ($fn) { - case 'createUser' : - case 'modifyUser' : - case 'deleteUsers' : - case 'joinGroup' : - case 'leaveGroup' : - return (@is_writable(AUTH_USERFILE)); - } - - return method_exists($this, $fn); - } - /** * Check user+password [required auth function] * @@ -264,40 +255,6 @@ class auth_plain extends auth_basic { return $out; } - /** - * Give user membership of a group - * - * @author Chris Smith - * @return bool - */ - function joinGroup($user, $group) { - - // sanity checks, user must exist, and not currently a group member - if (($userinfo = $this->getUserData($user)) === false) return false; - if (in_array($group, $userinfo['grps'])) return true; - - $userinfo['grps'][] = $group; - - return $this->modifyUser($user, array('grps' => $userinfo['grps'])); - } - - /** - * Remove user from a group - * - * @author Chris Smith - * @return bool - */ - function leaveGroup($user, $group) { - - // sanity checks, user must exist, and currently be a group member - if (($userinfo = $this->getUserData($user)) === false) return false; - if (($i = array_search($group, $userinfo['grps'])) === false) return true; - - array_splice($userinfo['grps'],$i,1); - - return $this->modifyUser($user, array('grps' => $userinfo['grps'])); - } - /** * Load all user data * -- cgit v1.2.3