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

20 add preferred client mode (#21)


* Add the preferred client mode to PIResponse

* Update tests

* Update composer.yml

run tests

* Update and rename composer.yml to RunTests.yml

add phpunit tests to workflow

* Update RunTests.yml

* Create phpunit.xml

* Update RunTests.yml

* Update RunTests.yml

* Update RunTests.yml

* Update and rename test/phpunit.xml to test/utils/phpunit.xml

* Update phpunit.xml

* Update RunTests.yml

* Update RunTests.yml

* Update RunTests.yml

* Update RunTests.yml

* Update RunTests.yml

* Update RunTests.yml

* Update RunTests.yml

* Update phpunit.xml

* Update RunTests.yml

* Update RunTests.yml

* Update phpunit.xml

* Update RunTests.yml

* Create RunUnitTests.yml

* Delete .github directory

Co-authored-by: default avatarNils Behlen <29949516+nilsbehlen@users.noreply.github.com>
parent 23fc2da1
No related branches found
No related tags found
No related merge requests found
......@@ -13,6 +13,9 @@ class PIResponse
/* @var string TransactionID is used to reference the challenges contained in this response in later requests. */
public $transactionID = "";
/* @var string Preferred mode in which client should work after triggering challenges. */
public $preferredClientMode = "";
/* @var string Raw response in JSON format. */
public $raw = "";
......@@ -85,6 +88,10 @@ class PIResponse
{
$ret->transactionID = $map['detail']['transaction_id'];
}
if (isset($map['detail']['preferred_client_mode']))
{
$ret->preferredClientMode = $map['detail']['preferred_client_mode'];
}
// Check that the authentication status is one of the allowed ones
$r = null;
......@@ -154,7 +161,7 @@ class PIResponse
$tmp->u2fSignRequest = json_encode($t);
}
array_push($ret->multiChallenge, $tmp);
$ret->multiChallenge[] = $tmp;
}
}
return $ret;
......@@ -182,12 +189,12 @@ class PIResponse
{
foreach ($this->multiChallenge as $challenge)
{
if ($challenge->type !== "push" && $challenge->type !== "webauthn")
if ($challenge->type !== "push" && $challenge->type !== "webauthn" && $challenge->type !== "u2f")
{
return $challenge->message;
}
}
return false;
return "";
}
/**
......
......@@ -40,7 +40,7 @@ class PollTransactionTest extends TestCase implements PILog
*/
public function testTriggerPUSH()
{
$responseBody = "{\n" . " \"detail\": {\n" . " \"attributes\": null,\n" .
$responseBody = "{\n" . " \"detail\": {\n" . "\"preferred_client_mode\":\"push\"," . " \"attributes\": null,\n" .
" \"message\": \"Bitte geben Sie einen OTP-Wert ein: , Please confirm the authentication on your mobile device!\",\n" .
" \"messages\": [\n" . " \"Bitte geben Sie einen OTP-Wert ein: \",\n" .
" \"Please confirm the authentication on your mobile device!\"\n" . " ],\n" .
......@@ -75,6 +75,7 @@ class PollTransactionTest extends TestCase implements PILog
$this->assertEquals("Bitte geben Sie einen OTP-Wert ein: , Please confirm the authentication on your mobile device!", $response->message);
$this->assertEquals("Bitte geben Sie einen OTP-Wert ein: , Please confirm the authentication on your mobile device!", $response->messages);
$this->assertEquals("02659936574063359702", $response->transactionID);
$this->assertEquals("push", $response->preferredClientMode);
$this->assertIsArray($response->multiChallenge);
$this->assertTrue($response->status);
$this->assertFalse($response->value);
......
......@@ -42,7 +42,7 @@ class TriggerChallengeTest extends TestCase implements PILog
*/
public function testTriggerChallengeSuccess()
{
$responseBody = "{\"detail\":{" . "\"attributes\":null," . "\"message\":\"BittegebenSieeinenOTP-Wertein:\"," .
$responseBody = "{\"detail\":{" . "\"preferred_client_mode\":\"interactive\"," . "\"attributes\":null," . "\"message\":\"BittegebenSieeinenOTP-Wertein:\"," .
"\"messages\":[\"BittegebenSieeinenOTP-Wertein:\"]," . "\"multi_challenge\":[{" .
"\"attributes\":null," . "\"message\":\"BittegebenSieeinenOTP-Wertein:\"," .
"\"serial\":\"TOTP00021198\"," . "\"transaction_id\":\"16734787285577957577\"," .
......@@ -85,6 +85,7 @@ class TriggerChallengeTest extends TestCase implements PILog
$this->assertEquals("BittegebenSieeinenOTP-Wertein:", $response->message);
$this->assertEquals("BittegebenSieeinenOTP-Wertein:", $response->messages);
$this->assertEquals("16734787285577957577", $response->transactionID);
$this->assertEquals("interactive", $response->preferredClientMode);
$this->assertTrue($response->status);
$this->assertFalse($response->value);
$this->assertEquals("totp", $response->triggeredTokenTypes()[0]);
......
......@@ -117,6 +117,7 @@ class ValidateCheckTest extends TestCase implements PILog
$this->assertEquals("904", $response->errorCode);
$this->assertEquals("ERR904: The user can not be found in any resolver in this realm!", $response->errorMessage);
$this->assertFalse($response->status);
$this->assertEquals("", $response->otpMessage());
}
public function piDebug($message)
......
......@@ -47,7 +47,7 @@ class ValidateCheckU2FTest extends TestCase implements PILog
"\"keyHandle\":\"UUHmZ4BUFCrt7q88MhlQJYu4G5qB9l7ScjRRxA-M35cTH-uHWyMEpxs4WBzbkjlZqzZW1lC-jDdFd2pKDUsNnA\"," .
"\"version\":\"U2F_V2\"}";
$responseBody = "{" . "\"detail\":{" . "\"attributes\":{" . "\"hideResponseInput\":true," .
$responseBody = "{" . "\"detail\":{" . "\"preferred_client_mode\":\"u2f\"," . "\"attributes\":{" . "\"hideResponseInput\":true," .
"\"img\":\"static/img/FIDO-U2F-Security-Key-444x444.png\"," . "\"u2fSignRequest\":{" .
"\"appId\":\"http//ttype.u2f\"," . "\"challenge\":\"TZKiB0VFFMF...tQduDJf56AeJAY_BT4NU\"," .
"\"keyHandle\":\"UUHmZ4BUFCrt7q88MhlQ...qzZW1lC-jDdFd2pKDUsNnA\"," .
......@@ -81,6 +81,7 @@ class ValidateCheckU2FTest extends TestCase implements PILog
$this->assertEquals("Please confirm with your U2F token (Yubico U2F EE Serial 61730834)", $response->message);
$this->assertEquals("Please confirm with your U2F token (Yubico U2F EE Serial 61730834)", $response->messages);
$this->assertEquals("12399202888279169736", $response->transactionID);
$this->assertEquals("u2f", $response->preferredClientMode);
$this->assertIsArray($response->multiChallenge);
$this->assertTrue($response->status);
$this->assertFalse($response->value);
......
......@@ -55,7 +55,7 @@ class ValidateCheckWebauthnTest extends TestCase implements PILog
" \"userVerification\": \"preferred\"\n" . " }\n";
$responseBody =
"{\n" . " \"detail\": {\n" . " \"attributes\": {\n" . " \"hideResponseInput\": true,\n" .
"{\n" . " \"detail\": {\n" . "\"preferred_client_mode\":\"webauthn\"," . " \"attributes\": {\n" . " \"hideResponseInput\": true,\n" .
" \"img\": \"static/img/FIDO-U2F-Security-Key-444x444.png\",\n" .
" \"webAuthnSignRequest\": {\n" . " \"allowCredentials\": [\n" . " {\n" .
" \"id\": \"83De8z_CNqogB6aCyKs6dWIqwpOpzVoNaJ74lgcpuYN7l-95QsD3z-qqPADqsFlPwBXCMqEPssq75kqHCMQHDA\",\n" .
......@@ -95,6 +95,7 @@ class ValidateCheckWebauthnTest extends TestCase implements PILog
$this->assertEquals("Please confirm with your WebAuthn token (Yubico U2F EE Serial 61730834)", $response->message);
$this->assertEquals("Please confirm with your WebAuthn token (Yubico U2F EE Serial 61730834)", $response->messages);
$this->assertEquals("16786665691788289392", $response->transactionID);
$this->assertEquals("webauthn", $response->preferredClientMode);
$this->assertEquals("16786665691788289392", $response->multiChallenge[0]->transactionID);
$this->assertEquals("Please confirm with your WebAuthn token (Yubico U2F EE Serial 61730834)", $response->multiChallenge[0]->message);
$this->assertEquals("WAN00025CE7", $response->multiChallenge[0]->serial);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment