Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 28 additions & 30 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ on:
branches:
- main
pull_request:
branches:
- main
workflow_dispatch:

permissions:
Expand All @@ -16,31 +14,31 @@ jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Set up FusionAuth
working-directory: .github/fusionauth
run: docker compose up -d

- name: Validate composer.json and composer.lock
run: |
composer update
composer validate

- name: Cache Composer packages
id: composer-cache
uses: actions/cache@v4
with:
path: vendor
key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-php-

- name: Install dependencies
run: composer install --prefer-dist --no-progress

- name: Waiting for FusionAuth App
run: timeout 30 bash -c 'while [[ "$(curl -s -o /dev/null -w ''%{http_code}'' localhost:9011)" != "200" ]]; do sleep 5; done' || false

- name: Run test suite
run: composer run test
- uses: actions/checkout@v4

- name: Set up FusionAuth
working-directory: .github/fusionauth
run: docker compose up -d

- name: Validate composer.json and composer.lock
run: |
composer update
composer validate

- name: Cache Composer packages
id: composer-cache
uses: actions/cache@v4
with:
path: vendor
key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-php-

- name: Install dependencies
run: composer install --prefer-dist --no-progress

- name: Waiting for FusionAuth App
run: timeout 30 bash -c 'while [[ "$(curl -s -o /dev/null -w ''%{http_code}'' localhost:9011)" != "200" ]]; do sleep 5; done' || false

- name: Run test suite
run: composer run test
108 changes: 108 additions & 0 deletions src/FusionAuth/FusionAuthClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,22 @@ public function commentOnUser($request)
->go();
}

/**
* Completes verification of an identity using verification codes from the Verify Start API.
*
* @param array $request The identity verify complete request that contains all the information used to verify the identity.
*
* @return ClientResponse The ClientResponse.
* @throws \Exception
*/
public function completeVerifyIdentity($request)
{
return $this->start()->uri("/api/identity/verify/complete")
->bodyHandler(new JSONBodyHandler($request))
->post()
->go();
}

/**
* Complete a WebAuthn authentication ceremony by validating the signature against the previously generated challenge without logging the user in
*
Expand Down Expand Up @@ -4419,6 +4435,24 @@ public function retrieveUserByLoginId($loginId)
->go();
}

/**
* Retrieves the user for the loginId, using specific loginIdTypes.
*
* @param string $loginId The email or username of the user.
* @param array $loginIdTypes the identity types that FusionAuth will compare the loginId to.
*
* @return ClientResponse The ClientResponse.
* @throws \Exception
*/
public function retrieveUserByLoginIdWithLoginIdTypes($loginId, $loginIdTypes)
{
return $this->start()->uri("/api/user")
->urlParameter("loginId", $loginId)
->urlParameter("loginIdTypes", $loginIdTypes)
->get()
->go();
}

/**
* Retrieves the user for the given username.
*
Expand Down Expand Up @@ -4648,6 +4682,31 @@ public function retrieveUserLoginReportByLoginId($applicationId, $loginId, $star
->go();
}

/**
* 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
* login counts for that application.
*
* @param string $applicationId (Optional) The application id.
* @param string $loginId The userId id.
* @param array $start The start instant as UTC milliseconds since Epoch.
* @param array $end The end instant as UTC milliseconds since Epoch.
* @param array $loginIdTypes the identity types that FusionAuth will compare the loginId to.
*
* @return ClientResponse The ClientResponse.
* @throws \Exception
*/
public function retrieveUserLoginReportByLoginIdAndLoginIdTypes($applicationId, $loginId, $start, $end, $loginIdTypes)
{
return $this->start()->uri("/api/report/login")
->urlParameter("applicationId", $applicationId)
->urlParameter("loginId", $loginId)
->urlParameter("start", $start)
->urlParameter("end", $end)
->urlParameter("loginIdTypes", $loginIdTypes)
->get()
->go();
}

/**
* Retrieves the last number of login records for a user.
*
Expand Down Expand Up @@ -5473,6 +5532,22 @@ public function sendTwoFactorCodeForLoginUsingMethod($twoFactorId, $request)
->go();
}

/**
* Send a verification code using the appropriate transport for the identity type being verified.
*
* @param array $request The identity verify send request that contains all the information used send the code.
*
* @return ClientResponse The ClientResponse.
* @throws \Exception
*/
public function sendVerifyIdentity($request)
{
return $this->start()->uri("/api/identity/verify/send")
->bodyHandler(new JSONBodyHandler($request))
->post()
->go();
}

/**
* Begins a login request for a 3rd party login that requires user interaction such as HYPR.
*
Expand Down Expand Up @@ -5528,6 +5603,23 @@ public function startTwoFactorLogin($request)
->go();
}

/**
* Start a verification of an identity by generating a code. This code can be sent to the User using the Verify Send API
* Verification Code API or using a mechanism outside of FusionAuth. The verification is completed by using the Verify Complete API with this code.
*
* @param array $request The identity verify start request that contains all the information used to begin the request.
*
* @return ClientResponse The ClientResponse.
* @throws \Exception
*/
public function startVerifyIdentity($request)
{
return $this->start()->uri("/api/identity/verify/start")
->bodyHandler(new JSONBodyHandler($request))
->post()
->go();
}

/**
* Start a WebAuthn authentication ceremony by generating a new challenge for the user
*
Expand Down Expand Up @@ -6274,6 +6366,22 @@ public function verifyEmailAddressByUserId($request)
->go();
}

/**
* Administratively verify a user identity.
*
* @param array $request The identity verify request that contains information to verify the identity.
*
* @return ClientResponse The ClientResponse.
* @throws \Exception
*/
public function verifyIdentity($request)
{
return $this->start()->uri("/api/identity/verify")
->bodyHandler(new JSONBodyHandler($request))
->post()
->go();
}

/**
* Confirms an application registration. The Id given is usually from an email sent to the user.
*
Expand Down
15 changes: 15 additions & 0 deletions tests/FusionAuth/FusionAuthClientTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,21 @@ public function testCanHandleUsers(): void
$this->handleResponse($response);
$this->assertEquals("test@fusionauth.io", $response->successResponse->user->email);

// retrieve by login Id (default types)
$response = $this->client->retrieveUserByLoginId("test@fusionauth.io");
$this->handleResponse($response);
$this->assertEquals("test@fusionauth.io", $response->successResponse->user->email);

// retrieve by login Id (explicit types)
$response = $this->client->retrieveUserByLoginIdWithLoginIdTypes("test@fusionauth.io", ["email"]);
$this->handleResponse($response);
$this->assertEquals("test@fusionauth.io", $response->successResponse->user->email);

// retrieve by login Id (not found, wrong type)
// TODO: will pass once issue 1 is live
// $response = $this->client->retrieveUserByLoginIdWithLoginIdTypes("test@fusionauth.io", ["phoneNumber"]);
// $this->assertEquals(404, $response->status);

// Login
$response = $this->client->login(["loginId" => "test@fusionauth.io", "password" => "password"]);
$this->handleResponse($response);
Expand Down