Skip to content
Snippets Groups Projects
Unverified Commit 19c9a6c4 authored by lukasmatusiewicz's avatar lukasmatusiewicz Committed by GitHub
Browse files

Merge pull request #31 from privacyidea/28-use-the-image-tag

28 use the image tag
parents c001e079 f3ed4828
No related branches found
No related tags found
No related merge requests found
......@@ -11,7 +11,7 @@ class PIChallenge
public $message = "";
/* @var string Image data for this challenge. */
public $img = "";
public $image = "";
/* @var string TransactionId to reference this challenge in later requests. */
public $transactionID = "";
......
......@@ -163,15 +163,13 @@ class PIResponse
$tmp->message = $challenge['message'];
$tmp->serial = $challenge['serial'];
$tmp->type = $challenge['type'];
if (isset($challenge['image']))
{
$tmp->image = $challenge['image'];
}
if (isset($challenge['attributes']))
{
$tmp->attributes = $challenge['attributes'];
// Search for the img
if ($challenge["attributes"]["img"])
{
$tmp->img = $challenge['attributes']['img'];
}
}
if (isset($challenge['client_mode']))
{
......@@ -183,7 +181,6 @@ class PIResponse
$t = $challenge['attributes']['webAuthnSignRequest'];
$tmp->webAuthnSignRequest = json_encode($t);
}
if ($tmp->type === "u2f")
{
$t = $challenge['attributes']['u2fSignRequest'];
......
......@@ -47,7 +47,7 @@ class TriggerChallengeTest extends TestCase implements PILog
"\"attributes\":null," . "\"message\":\"BittegebenSieeinenOTP-Wertein:\"," .
"\"messages\":[\"BittegebenSieeinenOTP-Wertein:\"]," . "\"multi_challenge\":[{" .
"\"attributes\":null," . "\"message\":\"BittegebenSieeinenOTP-Wertein:\"," .
"\"serial\":\"TOTP00021198\"," . "\"client_mode\":\"interactive\"," .
"\"serial\":\"TOTP00021198\"," . "\"client_mode\":\"interactive\"," . "\"image\":\"dataimage\"," .
"\"transaction_id\":\"16734787285577957577\"," . "\"type\":\"totp\"}]," . "\"serial\":\"TOTP00021198\"," .
"\"threadid\":140050885818112," . "\"transaction_id\":\"16734787285577957577\"," .
"\"transaction_ids\":[\"16734787285577957577\"]," . "\"type\":\"totp\"}," . "\"id\":1," .
......@@ -83,6 +83,7 @@ class TriggerChallengeTest extends TestCase implements PILog
$this->pi->serviceAccountRealm = "testServiceRealm";
$response = $this->pi->triggerchallenge("testUser");
$multiChallenge = $response->multiChallenge;
$multiChallenge = $response->multiChallenge;
......@@ -98,6 +99,7 @@ class TriggerChallengeTest extends TestCase implements PILog
$this->assertEquals("", $response->webauthnMessage());
$this->assertEquals("", $response->u2fMessage());
$this->assertEquals("", $response->pushMessage());
$this->assertEquals("dataimage", $multiChallenge[0]->image);
$this->assertEquals("interactive", $multiChallenge[0]->clientMode);
}
......
......@@ -42,7 +42,7 @@ class ValidateCheckWebauthnTest extends TestCase implements PILog
*/
public function testTriggerWebAuthn()
{
$webauthnrequest = "{\n" . " \"allowCredentials\": [\n" . " {\n" .
$webauthnSignRequest = "{\n" . " \"allowCredentials\": [\n" . " {\n" .
" \"id\": \"83De8z_CNqogB6aCyKs6dWIqwpOpzVoNaJ74lgcpuYN7l-95QsD3z-qqPADqsFlPwBXCMqEPssq75kqHCMQHDA\",\n" .
" \"transports\": [\n" . " \"internal\",\n" .
" \"nfc\",\n" . " \"ble\",\n" .
......@@ -70,10 +70,10 @@ class ValidateCheckWebauthnTest extends TestCase implements PILog
" \"Please confirm with your WebAuthn token (Yubico U2F EE Serial 61730834)\"\n" . " ],\n" .
" \"multi_challenge\": [\n" . " {\n" . " \"attributes\": {\n" .
" \"hideResponseInput\": true,\n" .
" \"img\": \"static/img/FIDO-U2F-Security-Key-444x444.png\",\n" .
" \"webAuthnSignRequest\": " . $webauthnrequest . " },\n" .
" \"webAuthnSignRequest\": " . $webauthnSignRequest . " },\n" .
" \"message\": \"Please confirm with your WebAuthn token (Yubico U2F EE Serial 61730834)\",\n" .
" \"serial\": \"WAN00025CE7\",\n" . " \"transaction_id\": \"16786665691788289392\",\n" .
" \"serial\": \"WAN00025CE7\",\n" . " \"image\": \"dataimage\",\n" .
" \"transaction_id\": \"16786665691788289392\",\n" .
" \"type\": \"webauthn\"\n" . " }\n" . " ],\n" . " \"serial\": \"WAN00025CE7\",\n" .
" \"threadid\": 140040275289856,\n" . " \"transaction_id\": \"16786665691788289392\",\n" .
" \"transaction_ids\": [\n" . " \"16786665691788289392\"\n" . " ],\n" .
......@@ -100,12 +100,11 @@ class ValidateCheckWebauthnTest extends TestCase implements PILog
$this->assertEquals("Please confirm with your WebAuthn token (Yubico U2F EE Serial 61730834)", $response->multiChallenge[0]->message);
$this->assertEquals("WAN00025CE7", $response->multiChallenge[0]->serial);
$this->assertEquals("webauthn", $response->multiChallenge[0]->type);
$this->assertArrayHasKey("img", $response->multiChallenge[0]->attributes);
$this->assertEquals("static/img/FIDO-U2F-Security-Key-444x444.png", $response->multiChallenge[0]->img);
$this->assertEquals("dataimage", $response->multiChallenge[0]->image);
$this->assertTrue($response->status);
$this->assertFalse($response->value);
$this->assertEquals("Please confirm with your WebAuthn token (Yubico U2F EE Serial 61730834)", $response->webauthnMessage());
$temp = str_replace(" ", "", $webauthnrequest);
$temp = str_replace(" ", "", $webauthnSignRequest);
$trimmedSignRequest = str_replace("\n", "", $temp);
$this->assertEquals($trimmedSignRequest, $response->webauthnSignRequest());
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment