summaryrefslogtreecommitdiff
path: root/inc/auth
diff options
context:
space:
mode:
authorchris <chris@jalakai.co.uk>2006-01-25 01:01:25 +0100
committerchris <chris@jalakai.co.uk>2006-01-25 01:01:25 +0100
commitcd52f92def16e676c2458a32d2b8c8f8a7839f06 (patch)
tree07d70db3e87c3dc543a49412e3a2e01d286d27ca /inc/auth
parent10ea5c9fe4098c14d01c3e731f45008458de619a (diff)
downloadrpg-cd52f92def16e676c2458a32d2b8c8f8a7839f06.tar.gz
rpg-cd52f92def16e676c2458a32d2b8c8f8a7839f06.tar.bz2
oo auth update - remove legacy auth remnants, add auth->canDo
darcs-hash:20060125000125-9b6ab-9853f11e04d8ea93235317fa8137cef079eb2641.gz
Diffstat (limited to 'inc/auth')
-rw-r--r--inc/auth/basic.class.php26
-rw-r--r--inc/auth/plain.class.php35
2 files changed, 60 insertions, 1 deletions
diff --git a/inc/auth/basic.class.php b/inc/auth/basic.class.php
index f39a9c392..9ea1a598b 100644
--- a/inc/auth/basic.class.php
+++ b/inc/auth/basic.class.php
@@ -5,13 +5,26 @@
* foundation authorisation class
* all auth classes should inherit from this class
*
- * @author Chris Smith <chris@jalakaic.co.uk>
+ * @author Chris Smith <chris@jalakai.co.uk>
*/
class auth_basic {
var $success = true;
+ /**
+ * Constructor
+ *
+ * Carry out sanity checks to ensure the object is
+ * able to operate.
+ *
+ * Set $this->success to false if checks fail
+ *
+ * @author Christopher Smith <chris@jalakai.co.uk>
+ */
+# function auth_basic() {
+# }
+
/**
* Do all authentication [ OPTIONAL ]
*
@@ -60,6 +73,17 @@ class auth_basic {
# return 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) {
+ return method_exists($this, $fn);
+ }
+
/**
* Check user+password [ MUST BE OVERRIDDEN ]
*
diff --git a/inc/auth/plain.class.php b/inc/auth/plain.class.php
index 2331ae908..373bb2907 100644
--- a/inc/auth/plain.class.php
+++ b/inc/auth/plain.class.php
@@ -20,6 +20,41 @@ class auth_plain extends auth_basic {
var $users = null;
var $_pattern = array();
+
+ /**
+ * Constructor
+ *
+ * Carry out sanity checks to ensure the object is
+ * able to operate.
+ *
+ * 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;
+ }
+
+ /**
+ * 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]