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

23 implement token enrollment via validatecheck (#26)


* Update PIResponse.php

* Update PIChallenge.php

* update tests

* Update TriggerChallengeTest.php

bugfix

* Update runTests.yml

* Delete checkComposer.yml

* Update runTests.yml

Co-authored-by: default avatarNils Behlen <29949516+nilsbehlen@users.noreply.github.com>
parent caea1051
Branches
Tags
No related merge requests found
name: PHP & Composer
on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
jobs:
build:
permissions:
write-all
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Validate composer.json and composer.lock
run: composer validate
- name: Check PHP installation
run: php -m
- name: Check PHP packages
run: dpkg --get-selections | grep -i php
name: Run tests and cov report
name: Check composer, run tests with cov report
on:
push:
......@@ -17,6 +17,15 @@ jobs:
steps:
- uses: actions/checkout@v3
- name: Validate composer.json and composer.lock
run: composer validate
- name: Check PHP installation
run: php -m
- name: Check PHP packages
run: dpkg --get-selections | grep -i php
- name: Install dependencies
uses: php-actions/composer@v6
with:
......
......@@ -10,6 +10,9 @@ class PIChallenge
/* @var string Message for this challenge. */
public $message = "";
/* @var string Image data for this challenge. */
public $img = "";
/* @var string TransactionId to reference this challenge in later requests. */
public $transactionID = "";
......
......@@ -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 QR Code to enroll a new token. */
public $image = "";
/* @var string Preferred mode in which client should work after triggering challenges. */
public $preferredClientMode = "";
......@@ -88,6 +91,10 @@ class PIResponse
{
$ret->transactionID = $map['detail']['transaction_id'];
}
if (isset($map['detail']['image']))
{
$ret->image = $map['detail']['image'];
}
if (isset($map['detail']['preferred_client_mode']))
{
$pref = $map['detail']['preferred_client_mode'];
......@@ -159,6 +166,12 @@ class PIResponse
if (isset($challenge['attributes']))
{
$tmp->attributes = $challenge['attributes'];
// Search for the img
if ($challenge["attributes"]["img"])
{
$tmp->img = $challenge['attributes']['img'];
}
}
if ($tmp->type === "webauthn")
......
......@@ -42,7 +42,9 @@ class TriggerChallengeTest extends TestCase implements PILog
*/
public function testTriggerChallengeSuccess()
{
$responseBody = "{\"detail\":{" . "\"preferred_client_mode\":\"interactive\"," . "\"attributes\":null," . "\"message\":\"BittegebenSieeinenOTP-Wertein:\"," .
$responseBody = "{\"detail\":{" . "\"preferred_client_mode\":\"interactive\"," .
"\"image\": \"data:image/png;base64,iVBdgfgsdfgRK5CYII=\",\n" .
"\"attributes\":null," . "\"message\":\"BittegebenSieeinenOTP-Wertein:\"," .
"\"messages\":[\"BittegebenSieeinenOTP-Wertein:\"]," . "\"multi_challenge\":[{" .
"\"attributes\":null," . "\"message\":\"BittegebenSieeinenOTP-Wertein:\"," .
"\"serial\":\"TOTP00021198\"," . "\"transaction_id\":\"16734787285577957577\"," .
......@@ -86,6 +88,7 @@ class TriggerChallengeTest extends TestCase implements PILog
$this->assertEquals("BittegebenSieeinenOTP-Wertein:", $response->messages);
$this->assertEquals("16734787285577957577", $response->transactionID);
$this->assertEquals("otp", $response->preferredClientMode);
$this->assertEquals("data:image/png;base64,iVBdgfgsdfgRK5CYII=", $response->image);
$this->assertTrue($response->status);
$this->assertFalse($response->value);
$this->assertEquals("totp", $response->triggeredTokenTypes()[0]);
......
......@@ -101,6 +101,7 @@ class ValidateCheckWebauthnTest extends TestCase implements PILog
$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->assertTrue($response->status);
$this->assertFalse($response->value);
$this->assertEquals("Please confirm with your WebAuthn token (Yubico U2F EE Serial 61730834)", $response->webauthnMessage());
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment