X-Git-Url: http://git.pjr.cc/?p=ga4php.git;a=blobdiff_plain;f=authserver%2Fusercmd.php;h=d24157e2ffa155cfd949934c31637a49f2473353;hp=d19fa54838a69c5af053080f517e3aa8bcb9cad8;hb=ef29f029690b3717a15adac4397047d9836e647c;hpb=1e9b1b3a5c4dd1f033ae5f3145d7bb7bcd73a4d6 diff --git a/authserver/usercmd.php b/authserver/usercmd.php index d19fa54..d24157e 100644 --- a/authserver/usercmd.php +++ b/authserver/usercmd.php @@ -37,15 +37,57 @@ if(!isset($argv[1])) { echo "\tgetusers: getusers - gets a list of users\n"; echo "\tgetotk: getotk - gets the OTKID for a key\n"; echo "\tradauth: radauth - for radius, only returns a code\n"; + echo "\tsynctoken: synctoken - resync's a hotp token based on two token codes\n"; + echo "\ttokentype: tokentype - gets the token type for a user\n"; + echo "\taddradclient: addradclient \"\"- adds a radius client\n"; + echo "\trmradclient: rmradclient - removes a radius client with the name \n"; + echo "\tgetradclients: getradclients - returns a list of radius clients\n"; return 0; } switch($argv[1]) { + case "rmradclient": + $msg = $myAC->deleteRadiusClient($argv[2]); + if($msg) { + echo "Successfully deleted\n"; + } + break; + case "getradclients": + $msg = $myAC->getRadiusClients(); + foreach($msg as $client) { + if($client["desc"]=="") $desc = "no description set"; + else $desc = $client["desc"]; + echo $client["name"]." is ".$client["ip"].", $desc\n"; + } + break; + case "addradclient": + $msg = $myAC->addRadiusClient($argv[2], $argv[3], $argv[4], $argv[5]); + if($msg === true) { + echo "Added successfully\n"; + } else if ($msg == "name") { + echo "Client with same name exists already\n"; + } else if ($msg == "ip") { + echo "Client with same IP already exists\n"; + } + break; + case "tokentype": + $msg = $myAC->getUserTokenType($argv[2]); + echo "token type: $msg\n"; + break; + case "synctoken": + if($myAC->syncUserToken($argv[2], $argv[3], $argv[4])) { + echo "Token synced\n"; + } else { + echo "Token not synced\n"; + } + break; case "radauth": if($myAC->authUserToken($argv[2], $argv[3])==1) { - return 0; + syslog(LOG_WARNING, "Got good request for user, ".$argv[2]); + exit(0); } else { - return 255; + syslog(LOG_WARNING, "Got bad request for user, ".$argv[2]); + exit(255); } break; case "getotk": @@ -65,7 +107,12 @@ switch($argv[1]) { break; case "add": $return = $myAC->addUser($argv[2]); - echo "Created user, ".$argv[2]." returned $return\n"; + if($return) { + echo "Created user, ".$argv[2]."\n"; + } else { + echo "Failed to create user, ".$argv[2]."\n"; + } + break; case "delete": $res = $myAC->deleteUser($argv[2]); @@ -118,5 +165,7 @@ switch($argv[1]) { echo "\tHas Token?: ".$hastoken."\n\n"; } break; + default: + echo "See the usage...\n"; } ?> \ No newline at end of file