Exemplo n.º 1
0
<?php

/*
 * 
 * 
 * This file is designed as a "script" extension to freeradius (or some such tool) for radius authentication.
 * Also provided is a simple web interface for managing users in freeradius.
 * 
 * The simple web interface should also provide a mechanism for configuring freeradius itself
 * 
 */
require_once "lib/authClient.php";
$myAC = new GAAuthClient();
/*
define("MSG_AUTH_USER_TOKEN", 1);
define("MSG_ADD_USER_TOKEN", 2);
define("MSG_DELETE_USER", 3);
define("MSG_AUTH_USER_PASSWORD", 4);
define("MSG_SET_USER_PASSWORD", 5);
define("MSG_SET_USER_REALNAME", 6);
define("MSG_SET_USER_TOKEN", 7);
define("MSG_SET_USER_TOKEN_TYPE", 8);
*/
if (!isset($argv[1])) {
    echo "Usage: " . $argv[0] . " command username [args]\n";
    echo "\tadd: add <username> - returns token code url\n";
    echo "\tauth: auth <username> <passcode> - returns 0/1 for pass/fail\n";
    echo "\tdelete: delete <username> - deletes user\n";
    echo "\tauthpass: authpass <username> <password> - returns 0/1 for pass/fail\n";
    echo "\tsetpass: setpass <username> <password> - sets a password for a user (x to remove pass)\n";
    echo "\tsetname: setname <username> <realname> - sets the real name for a user\n";
Exemplo n.º 2
0
<?php

require_once "../lib/authClient.php";
$myAC = new GAAuthClient();
$loggedin = false;
session_start();
if (isset($_SESSION["user_loggedin"])) {
    if ($_SESSION["user_loggedin"]) {
        $loggedin = true;
    } else {
        $loggedin = false;
    }
}
if (isset($_REQUEST["action"])) {
    error_log("action set: " . $_REQUEST["action"]);
    switch ($_REQUEST["action"]) {
        case "actuallygettoken":
            $otkid = $_REQUEST["otkid"];
            $username = $_REQUEST["username"];
            error_log("requesting otk, {$otk}");
            $otk_img = $myAC->getOtkPng($username, $otkid);
            header("Content-type: image/png");
            echo $otk_img;
            exit(0);
            break;
        case "login":
            error_log("being login");
            $username = $_REQUEST["username"];
            $token = $_REQUEST["tokencode"];
            if ($myAC->authUserToken($username, $token)) {
                $_SESSION["user_loggedin"] = true;
Exemplo n.º 3
0
<?php

require_once "../lib/authClient.php";
$myAC = new GAAuthClient();
session_start();
if (isset($_SESSION["loggedin"])) {
    if ($_SESSION["loggedin"]) {
        $loggedin = true;
    } else {
        $loggedin = false;
    }
}
if (isset($_REQUEST["action"])) {
    switch ($_REQUEST["action"]) {
        case "deleteradclient":
            $clientname = $_REQUEST["clientname"];
            $ret = $myAC->deleteRadiusClient($clientname);
            header("Location: ?message=" . urlencode("Client Deleted"));
            exit(0);
            break;
        case "addradclient":
            $clientname = $_REQUEST["clientname"];
            $clientip = $_REQUEST["clientip"];
            $clientsecret = $_REQUEST["clientsecret"];
            $clientdesc = $_REQUEST["clientdesc"];
            $ret = $myAC->addRadiusClient($clientname, $clientip, $clientsecret, $clientdesc);
            if ($ret === true) {
                header("Location: ?message=" . urlencode("Client Added"));
            } else {
                if ($ret == "name") {
                    header("Location: ?error=" . urlencode("Client Name Already Existed"));