-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3dcc7a7
commit 273e4fa
Showing
90 changed files
with
4,040 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# This file is a template for defining the environment variables | ||
# Set the application config values here | ||
|
||
YOTI_SCENARIO_ID=xxxxxxxxxxxxxxxx | ||
YOTI_SDK_ID=xxxxxxxxxxxxxxxxxxxxx | ||
|
||
# Below is the private key (in .pem format) associated with the Yoti Application you created on Yoti Hub | ||
YOTI_KEY_FILE_PATH=./keys/php-sdk-access-security.pem | ||
|
||
# Laravel config: | ||
APP_NAME=yoti.sdk.profile.demo | ||
APP_ENV=local | ||
APP_KEY= | ||
APP_DEBUG=true | ||
APP_URL=http://localhost |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
/node_modules | ||
/public/hot | ||
/public/storage | ||
/storage/*.key | ||
/vendor | ||
.env | ||
.env.backup | ||
.phpunit.result.cache | ||
Homestead.json | ||
Homestead.yaml | ||
npm-debug.log | ||
yarn-error.log | ||
|
||
*.pem | ||
keys/*.pem | ||
sdk |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# Profile Example | ||
|
||
## Requirements | ||
|
||
This example requires [Docker](https://docs.docker.com/) | ||
|
||
## Setup | ||
|
||
* Create your application in the [Yoti Hub](https://hub.yoti.com) (this requires having a Yoti account) | ||
* Set the application domain of your app to `localhost:4002` | ||
* Set the scenario callback URL to `/digitalidentity` | ||
* Do the steps below inside the [examples/digitaledentity](./) folder | ||
* Put `your-application-pem-file.pem` file inside the [keys](keys) folder, as Docker requires the `.pem` file to reside within the same location where it's run from. | ||
* Copy `.env.example` to `.env` | ||
* Open `.env` file and fill in the environment variables `YOTI_SCENARIO_ID`, `YOTI_SDK_ID` | ||
* Set `YOTI_KEY_FILE_PATH` to `./keys/your-application-pem-file.pem` | ||
* Install dependencies `docker-compose up composer` | ||
* Run the `docker-compose up --build` command | ||
* Visit [https://localhost:4002](https://localhost:4002) | ||
* Run the `docker-compose stop` command to stop the containers. | ||
|
||
> To see how to retrieve activity details using the one time use token, refer to the [digitalidentity controller](app/Http/Controllers/IdentityController.php) | ||
## Dynamic Share Example | ||
* Visit [/dynamic-share](https://localhost:4002/dynamic-share) | ||
|
||
> To see how to create a dynamic scenario, refer to the [dynamic share controller](app/Http/Controllers/DynamicShareController.php) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
<?php | ||
|
||
namespace App\Console; | ||
|
||
use Illuminate\Console\Scheduling\Schedule; | ||
use Illuminate\Foundation\Console\Kernel as ConsoleKernel; | ||
|
||
class Kernel extends ConsoleKernel | ||
{ | ||
/** | ||
* The Artisan commands provided by your application. | ||
* | ||
* @var array | ||
*/ | ||
protected $commands = [ | ||
// | ||
]; | ||
|
||
/** | ||
* Define the application's command schedule. | ||
* | ||
* @param \Illuminate\Console\Scheduling\Schedule $schedule | ||
* @return void | ||
*/ | ||
protected function schedule(Schedule $schedule) | ||
{ | ||
// $schedule->command('inspire')->hourly(); | ||
} | ||
|
||
/** | ||
* Register the commands for the application. | ||
* | ||
* @return void | ||
*/ | ||
protected function commands() | ||
{ | ||
$this->load(__DIR__.'/Commands'); | ||
|
||
require base_path('routes/console.php'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
<?php | ||
|
||
namespace App\Exceptions; | ||
|
||
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler; | ||
use Throwable; | ||
|
||
class Handler extends ExceptionHandler | ||
{ | ||
/** | ||
* A list of the exception types that are not reported. | ||
* | ||
* @var array | ||
*/ | ||
protected $dontReport = [ | ||
// | ||
]; | ||
|
||
/** | ||
* A list of the inputs that are never flashed for validation exceptions. | ||
* | ||
* @var array | ||
*/ | ||
protected $dontFlash = [ | ||
'password', | ||
'password_confirmation', | ||
]; | ||
|
||
/** | ||
* Report or log an exception. | ||
* | ||
* @param \Throwable $exception | ||
* @return void | ||
* | ||
* @throws \Exception | ||
*/ | ||
public function report(Throwable $exception) | ||
{ | ||
parent::report($exception); | ||
} | ||
|
||
/** | ||
* Render an exception into an HTTP response. | ||
* | ||
* @param \Illuminate\Http\Request $request | ||
* @param \Throwable $exception | ||
* @return \Symfony\Component\HttpFoundation\Response | ||
* | ||
* @throws \Throwable | ||
*/ | ||
public function render($request, Throwable $exception) | ||
{ | ||
return parent::render($request, $exception); | ||
} | ||
} |
52 changes: 52 additions & 0 deletions
52
examples/digitalidentity/app/Http/Controllers/DbsCheckController.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
<?php | ||
|
||
namespace App\Http\Controllers; | ||
|
||
use Illuminate\Routing\Controller as BaseController; | ||
use Yoti\ShareUrl\DynamicScenarioBuilder; | ||
use Yoti\ShareUrl\Policy\DynamicPolicyBuilder; | ||
use Yoti\YotiClient; | ||
|
||
class DbsCheckController extends BaseController | ||
{ | ||
public function show(YotiClient $client) | ||
{ | ||
$dynamicPolicy = (new DynamicPolicyBuilder()) | ||
->withIdentityProfileRequirements((object)[ | ||
'trust_framework' => 'UK_TFIDA', | ||
'scheme' => [ | ||
'type' => 'DBS', | ||
'objective' => 'BASIC' | ||
] | ||
]) | ||
->build(); | ||
|
||
$dynamicScenario = (new DynamicScenarioBuilder()) | ||
->withCallbackEndpoint("/profile") | ||
->withPolicy($dynamicPolicy) | ||
->withSubject((object)[ | ||
'subject_id' => "some_subject_id_string" | ||
]) | ||
->build(); | ||
|
||
return view('dbs', [ | ||
'title' => 'DBS Check Example', | ||
'buttonConfig' => [ | ||
'elements' => [ | ||
[ | ||
'domId' => 'yoti-share-button', | ||
'clientSdkId' => config('yoti')['client.sdk.id'], | ||
'shareUrl' => $client->createShareUrl($dynamicScenario)->getShareUrl(), | ||
'button' => [ | ||
'label' => 'Use Yoti', | ||
'align' => 'center', | ||
'width' => 'auto', | ||
'verticalAlign' => 'top' | ||
], | ||
'type' => 'modal' | ||
] | ||
] | ||
] | ||
]); | ||
} | ||
} |
55 changes: 55 additions & 0 deletions
55
examples/digitalidentity/app/Http/Controllers/DynamicShareController.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
<?php | ||
|
||
namespace App\Http\Controllers; | ||
|
||
use Yoti\YotiClient; | ||
use Illuminate\Routing\Controller as BaseController; | ||
use Yoti\ShareUrl\DynamicScenarioBuilder; | ||
use Yoti\ShareUrl\Extension\LocationConstraintExtensionBuilder; | ||
use Yoti\ShareUrl\Policy\DynamicPolicyBuilder; | ||
|
||
class DynamicShareController extends BaseController | ||
{ | ||
public function show(YotiClient $client) | ||
{ | ||
$locationConstraint = (new LocationConstraintExtensionBuilder()) | ||
->withLatitude(50.8169) | ||
->withLongitude(-0.1367) | ||
->withRadius(100000) | ||
->build(); | ||
|
||
$policy = (new DynamicPolicyBuilder()) | ||
->withFullName() | ||
->withDocumentDetails() | ||
->withDocumentImages() | ||
->withAgeOver(18) | ||
->withSelfie() | ||
->build(); | ||
|
||
$scenario = (new DynamicScenarioBuilder()) | ||
->withPolicy($policy) | ||
->withCallbackEndpoint('/profile') | ||
->withExtension($locationConstraint) | ||
->build(); | ||
|
||
return view('share', [ | ||
'title' => 'Dynamic Share Example', | ||
'buttonConfig' => [ | ||
'elements' => [ | ||
[ | ||
'domId' => 'yoti-share-button', | ||
'clientSdkId' => config('yoti')['client.sdk.id'], | ||
'shareUrl' => $client->createShareUrl($scenario)->getShareUrl(), | ||
'button' => [ | ||
'label' => 'Use Yoti', | ||
'align' => 'center', | ||
'width' => 'auto', | ||
'verticalAlign' => 'top' | ||
], | ||
'type' => 'modal' | ||
] | ||
] | ||
] | ||
]); | ||
} | ||
} |
78 changes: 78 additions & 0 deletions
78
examples/digitalidentity/app/Http/Controllers/Identity2Controller.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
<?php | ||
|
||
namespace App\Http\Controllers; | ||
|
||
use Illuminate\Routing\Controller as BaseController; | ||
use Illuminate\Support\Facades\Log; | ||
use Symfony\Component\HttpKernel\Exception\BadRequestHttpException; | ||
use Yoti\DigitalIdentityClient; | ||
use Yoti\Identity\Policy\PolicyBuilder; | ||
use Yoti\Identity\ShareSessionRequestBuilder; | ||
use Yoti\YotiClient; | ||
|
||
class Identity2Controller extends BaseController | ||
{ | ||
public function show(DigitalIdentityClient $client) | ||
{ | ||
try { | ||
|
||
$policy = (new PolicyBuilder()) | ||
->withFamilyName() | ||
->withGivenNames() | ||
->withFullName() | ||
->withDateOfBirth() | ||
->withGender() | ||
->withNationality() | ||
->withPhoneNumber() | ||
->withSelfie() | ||
->withEmail() | ||
->withDocumentDetails() | ||
->withDocumentImages() | ||
->build(); | ||
|
||
$redirectUri = 'https://host/redirect/'; | ||
|
||
$shareSessionRequest = (new ShareSessionRequestBuilder()) | ||
->withPolicy($policy) | ||
->withRedirectUri($redirectUri) | ||
->build(); | ||
|
||
$session = $client->createShareSession($shareSessionRequest); | ||
|
||
$createdQrCode = $client->createShareQrCode($session->getId()); | ||
|
||
$fetchedQrCode = $client->fetchShareQrCode($createdQrCode->getId()); | ||
|
||
$sessionFetched = $client->fetchShareSession($session->getId()); | ||
|
||
return view('identity2', [ | ||
'title' => 'Digital Identity Complete Example', | ||
// Creating session | ||
'sessionId' => $session->getId(), | ||
'sessionStatus' => $session->getStatus(), | ||
'sessionExpiry' => $session->getExpiry(), | ||
// Creating QR code | ||
'createdQrCodeId' => $createdQrCode->getId(), | ||
'createdQrCodeUri' => $createdQrCode->getUri(), | ||
// Fetch QR code | ||
'fetchedQrCodeExpiry' => $fetchedQrCode->getExpiry(), | ||
|
||
'fetchedQrCodeRedirectUri' => $fetchedQrCode->getRedirectUri(), | ||
'fetchedQrCodeSessionId' => $fetchedQrCode->getSession()->getId(), | ||
'fetchedQrCodeSessionStatus' => $fetchedQrCode->getSession()->getStatus(), | ||
'fetchedQrCodeSessionExpiry' => $fetchedQrCode->getSession()->getExpiry(), | ||
// Fetch session | ||
'fetchedSessionId' => $sessionFetched->getId(), | ||
'fetchedSessionStatus' => $sessionFetched->getStatus(), | ||
'fetchedSessionExpiry' => $sessionFetched->getExpiry(), | ||
'fetchedSessionCreated' => $sessionFetched->getCreated(), | ||
'fetchedSessionUpdated' => $sessionFetched->getUpdated(), | ||
'sdkId' => $client->id | ||
|
||
]); | ||
} catch (\Throwable $e) { | ||
Log::error($e->getTraceAsString()); | ||
throw new BadRequestHttpException($e->getMessage()); | ||
} | ||
} | ||
} |
Oops, something went wrong.