Skip to content

Commit fccd7e9

Browse files
wied03robotdanbhalseyspwitt
authored
Merge degroff/ENG-1/issue1 (#60)
* Updated version for fusionauth-php-client to 1.55.0 * Updated version for fusionauth-php-client to 1.56.0 * client builder regen (#44) * ENG-2608 - New APIs/method overloads (#51) * capture current cli state * add report method * let's run on all PRs * forgot PHP * test/issue 1 * revert overloads * test fixes * client correct/optional * now that this overload does not have opt params, remove defaults * client builder sb build * add /api/user/verify and request to clients (#53) * sb build follow up --------- Co-authored-by: Daniel DeGroff <daniel@fusionauth.io> Co-authored-by: Brent Halsey <brent.halsey@fusionauth.io> Co-authored-by: Spencer Witt <3409780+spwitt@users.noreply.github.com>
1 parent a46e042 commit fccd7e9

3 files changed

Lines changed: 151 additions & 30 deletions

File tree

.github/workflows/test.yaml

Lines changed: 28 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@ on:
55
branches:
66
- main
77
pull_request:
8-
branches:
9-
- main
108
workflow_dispatch:
119

1210
permissions:
@@ -16,31 +14,31 @@ jobs:
1614
test:
1715
runs-on: ubuntu-latest
1816
steps:
19-
- uses: actions/checkout@v4
20-
21-
- name: Set up FusionAuth
22-
working-directory: .github/fusionauth
23-
run: docker compose up -d
24-
25-
- name: Validate composer.json and composer.lock
26-
run: |
27-
composer update
28-
composer validate
29-
30-
- name: Cache Composer packages
31-
id: composer-cache
32-
uses: actions/cache@v4
33-
with:
34-
path: vendor
35-
key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }}
36-
restore-keys: |
37-
${{ runner.os }}-php-
38-
39-
- name: Install dependencies
40-
run: composer install --prefer-dist --no-progress
41-
42-
- name: Waiting for FusionAuth App
43-
run: timeout 30 bash -c 'while [[ "$(curl -s -o /dev/null -w ''%{http_code}'' localhost:9011)" != "200" ]]; do sleep 5; done' || false
44-
45-
- name: Run test suite
46-
run: composer run test
17+
- uses: actions/checkout@v4
18+
19+
- name: Set up FusionAuth
20+
working-directory: .github/fusionauth
21+
run: docker compose up -d
22+
23+
- name: Validate composer.json and composer.lock
24+
run: |
25+
composer update
26+
composer validate
27+
28+
- name: Cache Composer packages
29+
id: composer-cache
30+
uses: actions/cache@v4
31+
with:
32+
path: vendor
33+
key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }}
34+
restore-keys: |
35+
${{ runner.os }}-php-
36+
37+
- name: Install dependencies
38+
run: composer install --prefer-dist --no-progress
39+
40+
- name: Waiting for FusionAuth App
41+
run: timeout 30 bash -c 'while [[ "$(curl -s -o /dev/null -w ''%{http_code}'' localhost:9011)" != "200" ]]; do sleep 5; done' || false
42+
43+
- name: Run test suite
44+
run: composer run test

src/FusionAuth/FusionAuthClient.php

Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -347,6 +347,22 @@ public function commentOnUser($request)
347347
->go();
348348
}
349349

350+
/**
351+
* Completes verification of an identity using verification codes from the Verify Start API.
352+
*
353+
* @param array $request The identity verify complete request that contains all the information used to verify the identity.
354+
*
355+
* @return ClientResponse The ClientResponse.
356+
* @throws \Exception
357+
*/
358+
public function completeVerifyIdentity($request)
359+
{
360+
return $this->start()->uri("/api/identity/verify/complete")
361+
->bodyHandler(new JSONBodyHandler($request))
362+
->post()
363+
->go();
364+
}
365+
350366
/**
351367
* Complete a WebAuthn authentication ceremony by validating the signature against the previously generated challenge without logging the user in
352368
*
@@ -4419,6 +4435,24 @@ public function retrieveUserByLoginId($loginId)
44194435
->go();
44204436
}
44214437

4438+
/**
4439+
* Retrieves the user for the loginId, using specific loginIdTypes.
4440+
*
4441+
* @param string $loginId The email or username of the user.
4442+
* @param array $loginIdTypes the identity types that FusionAuth will compare the loginId to.
4443+
*
4444+
* @return ClientResponse The ClientResponse.
4445+
* @throws \Exception
4446+
*/
4447+
public function retrieveUserByLoginIdWithLoginIdTypes($loginId, $loginIdTypes)
4448+
{
4449+
return $this->start()->uri("/api/user")
4450+
->urlParameter("loginId", $loginId)
4451+
->urlParameter("loginIdTypes", $loginIdTypes)
4452+
->get()
4453+
->go();
4454+
}
4455+
44224456
/**
44234457
* Retrieves the user for the given username.
44244458
*
@@ -4648,6 +4682,31 @@ public function retrieveUserLoginReportByLoginId($applicationId, $loginId, $star
46484682
->go();
46494683
}
46504684

4685+
/**
4686+
* Retrieves the login report between the two instants for a particular user by login Id, using specific loginIdTypes. If you specify an application id, it will only return the
4687+
* login counts for that application.
4688+
*
4689+
* @param string $applicationId (Optional) The application id.
4690+
* @param string $loginId The userId id.
4691+
* @param array $start The start instant as UTC milliseconds since Epoch.
4692+
* @param array $end The end instant as UTC milliseconds since Epoch.
4693+
* @param array $loginIdTypes the identity types that FusionAuth will compare the loginId to.
4694+
*
4695+
* @return ClientResponse The ClientResponse.
4696+
* @throws \Exception
4697+
*/
4698+
public function retrieveUserLoginReportByLoginIdAndLoginIdTypes($applicationId, $loginId, $start, $end, $loginIdTypes)
4699+
{
4700+
return $this->start()->uri("/api/report/login")
4701+
->urlParameter("applicationId", $applicationId)
4702+
->urlParameter("loginId", $loginId)
4703+
->urlParameter("start", $start)
4704+
->urlParameter("end", $end)
4705+
->urlParameter("loginIdTypes", $loginIdTypes)
4706+
->get()
4707+
->go();
4708+
}
4709+
46514710
/**
46524711
* Retrieves the last number of login records for a user.
46534712
*
@@ -5473,6 +5532,22 @@ public function sendTwoFactorCodeForLoginUsingMethod($twoFactorId, $request)
54735532
->go();
54745533
}
54755534

5535+
/**
5536+
* Send a verification code using the appropriate transport for the identity type being verified.
5537+
*
5538+
* @param array $request The identity verify send request that contains all the information used send the code.
5539+
*
5540+
* @return ClientResponse The ClientResponse.
5541+
* @throws \Exception
5542+
*/
5543+
public function sendVerifyIdentity($request)
5544+
{
5545+
return $this->start()->uri("/api/identity/verify/send")
5546+
->bodyHandler(new JSONBodyHandler($request))
5547+
->post()
5548+
->go();
5549+
}
5550+
54765551
/**
54775552
* Begins a login request for a 3rd party login that requires user interaction such as HYPR.
54785553
*
@@ -5528,6 +5603,23 @@ public function startTwoFactorLogin($request)
55285603
->go();
55295604
}
55305605

5606+
/**
5607+
* Start a verification of an identity by generating a code. This code can be sent to the User using the Verify Send API
5608+
* Verification Code API or using a mechanism outside of FusionAuth. The verification is completed by using the Verify Complete API with this code.
5609+
*
5610+
* @param array $request The identity verify start request that contains all the information used to begin the request.
5611+
*
5612+
* @return ClientResponse The ClientResponse.
5613+
* @throws \Exception
5614+
*/
5615+
public function startVerifyIdentity($request)
5616+
{
5617+
return $this->start()->uri("/api/identity/verify/start")
5618+
->bodyHandler(new JSONBodyHandler($request))
5619+
->post()
5620+
->go();
5621+
}
5622+
55315623
/**
55325624
* Start a WebAuthn authentication ceremony by generating a new challenge for the user
55335625
*
@@ -6274,6 +6366,22 @@ public function verifyEmailAddressByUserId($request)
62746366
->go();
62756367
}
62766368

6369+
/**
6370+
* Administratively verify a user identity.
6371+
*
6372+
* @param array $request The identity verify request that contains information to verify the identity.
6373+
*
6374+
* @return ClientResponse The ClientResponse.
6375+
* @throws \Exception
6376+
*/
6377+
public function verifyIdentity($request)
6378+
{
6379+
return $this->start()->uri("/api/identity/verify")
6380+
->bodyHandler(new JSONBodyHandler($request))
6381+
->post()
6382+
->go();
6383+
}
6384+
62776385
/**
62786386
* Confirms an application registration. The Id given is usually from an email sent to the user.
62796387
*

tests/FusionAuth/FusionAuthClientTest.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,21 @@ public function testCanHandleUsers(): void
118118
$this->handleResponse($response);
119119
$this->assertEquals("test@fusionauth.io", $response->successResponse->user->email);
120120

121+
// retrieve by login Id (default types)
122+
$response = $this->client->retrieveUserByLoginId("test@fusionauth.io");
123+
$this->handleResponse($response);
124+
$this->assertEquals("test@fusionauth.io", $response->successResponse->user->email);
125+
126+
// retrieve by login Id (explicit types)
127+
$response = $this->client->retrieveUserByLoginIdWithLoginIdTypes("test@fusionauth.io", ["email"]);
128+
$this->handleResponse($response);
129+
$this->assertEquals("test@fusionauth.io", $response->successResponse->user->email);
130+
131+
// retrieve by login Id (not found, wrong type)
132+
// TODO: will pass once issue 1 is live
133+
// $response = $this->client->retrieveUserByLoginIdWithLoginIdTypes("test@fusionauth.io", ["phoneNumber"]);
134+
// $this->assertEquals(404, $response->status);
135+
121136
// Login
122137
$response = $this->client->login(["loginId" => "test@fusionauth.io", "password" => "password"]);
123138
$this->handleResponse($response);

0 commit comments

Comments
 (0)