diff options
author | Andreas Gohr <andi@splitbrain.org> | 2006-02-03 16:03:02 +0100 |
---|---|---|
committer | Andreas Gohr <andi@splitbrain.org> | 2006-02-03 16:03:02 +0100 |
commit | 82fd59b6cf8cda9b2c419fb08bbc40a571b36fe8 (patch) | |
tree | cddf8d28de73822bb0932f005f4056d925cc7025 /inc/auth/plain.class.php | |
parent | ce070a9f83cfdd14001e835635ff4e1a3f43f41c (diff) | |
download | rpg-82fd59b6cf8cda9b2c419fb08bbc40a571b36fe8.tar.gz rpg-82fd59b6cf8cda9b2c419fb08bbc40a571b36fe8.tar.bz2 |
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
Diffstat (limited to 'inc/auth/plain.class.php')
-rw-r--r-- | inc/auth/plain.class.php | 75 |
1 files changed, 16 insertions, 59 deletions
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,38 +25,29 @@ 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 <chris@jalakai.co.uk> */ 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 <chris@jalakai.co.uk> - * @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] * * Checks if the given user exists and the given @@ -265,40 +256,6 @@ class auth_plain extends auth_basic { } /** - * Give user membership of a group - * - * @author Chris Smith <chris@jalakai.co.uk> - * @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 <chris@jalakai.co.uk> - * @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 * * loads the user file into a datastructure |