Commit 5a5877ad authored by Brett Wilkins's avatar Brett Wilkins

MaharaAuthPlugin: Adding authentication function

parent 5e69ac3e
......@@ -29,7 +29,7 @@
* you can transparently create internal wiki accounts the first time
* someone logs in who can be authenticated externally.
*/
class MaharaAuth extends AuthPlugin {
class MaharaAuthPlugin extends AuthPlugin {
/**
* Check whether there exists a user account with the given name.
* The name will be normalized to MediaWiki's requirements, so
......@@ -57,7 +57,7 @@ class MaharaAuth extends AuthPlugin {
public function userExists( $username ) {
$db = new Database($this->dbhost,$this->dbuser,$this->dbpass,$this->dbname);
$sql = "SELECT username* FROM ".$this->prefix."usr where username = '".$username."';";
$sql = "SELECT username FROM ".$this->prefix."usr where username = '".$username."';";
$res = $db->query($sql);
$val = $db->fetchRow($res);
$db->close();
......@@ -78,7 +78,17 @@ class MaharaAuth extends AuthPlugin {
* @return bool
*/
public function authenticate( $username, $password ) {
# Override this!
$db = new Database($this->dbhost,$this->dbuser,$this->dbpass,$this->dbname);
$sql = "SELECT username, password, salt FROM ".$this->prefix."usr where username = '".$username"';"
$res = $db->query($sql);
$val = $db->fetchRow($res);
$db->close();
if (!empty($val) && $val > 0) {
$passcheck = sha1($val->salt . $password);
if ($passcheck == $val->password) {
return true;
}
}
return false;
}
......@@ -142,7 +152,7 @@ class MaharaAuth extends AuthPlugin {
* @return bool
*/
public function autoCreate() {
return false;
return true;
}
/**
......@@ -151,7 +161,7 @@ class MaharaAuth extends AuthPlugin {
* @return bool
*/
public function allowPasswordChange() {
return true;
return false;
}
/**
......@@ -167,7 +177,7 @@ class MaharaAuth extends AuthPlugin {
* @return bool
*/
public function setPassword( $user, $password ) {
return true;
return false;
}
/**
......@@ -178,7 +188,7 @@ class MaharaAuth extends AuthPlugin {
* @return bool
*/
public function updateExternalDB( $user ) {
return true;
return false;
}
/**
......@@ -201,7 +211,7 @@ class MaharaAuth extends AuthPlugin {
* @return bool
*/
public function addUser( $user, $password, $email='', $realname='' ) {
return true;
return false;
}
......@@ -214,7 +224,7 @@ class MaharaAuth extends AuthPlugin {
* @return bool
*/
public function strict() {
return false;
return true;
}
/**
......@@ -225,7 +235,7 @@ class MaharaAuth extends AuthPlugin {
* @return bool
*/
public function strictUserAuth( $username ) {
return false;
return true;
}
/**
......@@ -262,6 +272,7 @@ class MaharaAuth extends AuthPlugin {
}
}
/*
class AuthPluginUser {
function __construct( $user ) {
# Override this!
......@@ -286,4 +297,4 @@ class AuthPluginUser {
# Override this!
return true;
}
}
}*/
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment