Example #1
0
<?php

require_once 'lib/a2f_curl.php';
$action = $_REQUEST["sdk_call"];
$HOST = "";
$API_KEY = "";
$API_SECRET = "";
$a2f_client = new auth2factor($HOST, $API_KEY, $API_SECRET);
if ($action == "delegate") {
    header("Content-type:application/json");
    $u = $_POST["username"];
    $p = $_POST["password"];
    if ($u == NULL) {
        header('X-PHP-Response-Code: 400', true, 400);
        echo json_encode(array("error" => "Missing username"));
        return;
    }
    if ($p == NULL) {
        header('X-PHP-Response-Code: 400', true, 400);
        echo json_encode(array("error" => "Missing password"));
        return;
    }
    // 2FA - 1st leg
    $requests = $a2f_client->delegate($u);
    echo json_encode($requests);
    return;
} else {
    if ($action == "delegate_u2f") {
        header("Content-type:text/html");
        $u = $_GET["username"];
        if ($u == NULL) {
Example #2
0
<!-- READ http://unitstep.net/blog/2009/05/05/using-curl-in-php-to-access-https-ssltls-protected-sites/-->
<?php 
require __DIR__ . '/lib/a2f_guzzle.php';
$u = $_POST["username"];
$p = $_POST["password"];
header("Content-type:application/json");
if ($u == NULL) {
    header('X-PHP-Response-Code: 400', true, 400);
    echo json_encode(array("error" => "Missing username"));
    return;
}
if ($p == NULL) {
    header('X-PHP-Response-Code: 400', true, 400);
    echo json_encode(array("error" => "Missing password"));
    return;
}
$af_client = new auth2factor('http://localhost/api');
// $token = $af_client->authenticate($u, $p);
$token = $af_client->delegate($u);
echo json_encode(array("token" => $token));
return;