echo "Call to auth user token\n";
// minimal checking, we leav it up to authenticateUser to do the real
// checking
- if(!isset($msg["user"])) $msg["user"] = "";
+ if(!isset($msg["username"])) $msg["username"] = "";
if(!isset($msg["passcode"])) $msg["passcode"] = "";
- $username = $msg["user"];
+ $username = $msg["username"];
$passcode = $msg["passcode"];
global $myga;
- msg_send($cl_queue, MSG_AUTH_USER_TOKEN, $myga->authenticateUser($username, $passcode));
+ $authval = $myga->authenticateUser($username, $passcode);
+ msg_send($cl_queue, MSG_AUTH_USER_TOKEN, $authval);
break;
case MSG_ADD_USER_TOKEN:
echo "Call to add user token\n";
if(!isset($msg["username"])) {
msg_send($cl_queue, MSG_ADD_USER_TOKEN, false);
} else {
- $username = $msg["username"];
+ $username = $msg["username"];
+ $tokentype="HOTP";
+ if(isset($msg["tokentype"])) {
+ $tokentype="HOTP";
+ }
+ $hexkey = "";
+ if(isset($msg["hexkey"])) {
+ $hexkey = $msg["hexkey"];
+ }
global $myga;
- msg_send($cl_queue, MSG_ADD_USER_TOKEN, $myga->setUser($username));
+ $myga->setUser($username, $tokentype, "", $hexkey);
+
+ msg_send($cl_queue, MSG_ADD_USER_TOKEN, $myga->createUrl($username));
}
break;
case MSG_DELETE_USER:
$username = $msg["username"];
$realname = $msg["realname"];
$sql = "update users set users_realname='$realname' where users_username='$username'";
- echo "sql: $sql\n";
$dbo = getDatabase();
$dbo->query($sql);
}
global $myga;
- msg_send($cl_queue, MSG_SET_USER_TOKEN, $myga->setUserKey($username, $passcode));
+ $myga->setUserKey($username, $passcode);
+ msg_send($cl_queue, MSG_SET_USER_TOKEN, $myga->createUrl($username));
// TODO now set token
break;
$message["username"] = $username;
$message["passcode"] = $passcode;
- msg_send($sr_queue, MSG_AUTH_USER, $message, true, true, $msg_err);
+ msg_send($sr_queue, MSG_AUTH_USER_TOKEN, $message, true, true, $msg_err);
echo "message sent\n";
msg_receive($cl_queue, 0, $msg_type, 16384, $msg);
- echo "message received?\n";
- print_r($msg);
return $msg;
}
- function addUser($username) {
+ function addUser($username, $tokentype="", $hexkey="") {
global $MSG_QUEUE_KEY_ID_SERVER, $MSG_QUEUE_KEY_ID_CLIENT;
$message["username"] = $username;
+ if($tokentype!="") $message["tokentype"] = $tokentype;
+ if($hexkey!="") $message["hexkey"] = $hexkey;
msg_send($sr_queue, MSG_ADD_USER_TOKEN, $message, true, true, $msg_err);
- echo "message sent\n";
msg_receive($cl_queue, 0, $msg_type, 16384, $msg);
- echo "message received?\n";
- print_r($msg);
return $msg;
-
}
function setTokenType($username, $tokentype) {
class gaasGA extends GoogleAuthenticator {
function getData($username) {
+ echo "called into getdata\n";
// get our database connection
$dbObject = getDatabase();
$result = $dbObject->query($sql);
// check the result
+ echo "next1\n";
if(!$result) return false;
// now just retreieve all the data (there should only be one, but whatever)
+ echo "next2\n";
$tokendata = false;
foreach($result as $row) {
$tokendata = $row["users_tokendata"];
}
-
+
+ echo "next3, $username, $tokendata\n";
// now we have our data, we just return it. If we got no data
// we'll just return false by default
return $tokendata;
switch($argv[1]) {
case "auth":
- if($myAC->authUser($argv[2], $argv[3])==1) {
+ if($myAC->authUserToken($argv[2], $argv[3])==1) {
echo "Pass!";
} else {
echo "Fail!";
}
break;
case "add":
- $myAC->addUser($argv[2]);
+ $return = $myAC->addUser($argv[2]);
+ echo "Created user, ".$argv[2]." returned $return\n";
break;
case "delete":
$myAC->deleteUser($argv[2]);
switch($ttype) {
case "HOTP":
error_log("in hotp");
- $st = $tlid;
+ $st = $tlid+1;
$en = $tlid+$this->hotpSkew;
for($i=$st; $i<$en; $i++) {
$stest = $this->oath_hotp($tkey, $i);