Skip to content

Commit

Permalink
SDK-2371 added advanced identity profile to sharev1,example and updat… (
Browse files Browse the repository at this point in the history
#359)

* SDK-2371 added advanced identity profile to sharev1,example and updated tests
* SDK-2371 updated test coverage info
* SDK-2371 updated example page title
  • Loading branch information
mehmet-yoti authored Jul 4, 2024
1 parent d9442d5 commit f454c03
Show file tree
Hide file tree
Showing 7 changed files with 245 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
<?php

namespace App\Http\Controllers;

use Illuminate\Routing\Controller as BaseController;
use Yoti\ShareUrl\DynamicScenarioBuilder;
use Yoti\ShareUrl\Policy\DynamicPolicyBuilder;
use Yoti\YotiClient;

class AdvancedIdentityController extends BaseController
{
public function show(YotiClient $client)
{
$advancedIdentityProfileJson =
(object)[
"profiles" => [(object)[

"trust_framework" => "YOTI_GLOBAL",
"schemes" => [(object)[

"label" => "identity-AL-L1",
"type" => "IDENTITY",
"objective" => "AL_L1"
],
[
"label" => "identity-AL-M1",
"type" => "IDENTITY",
"objective" => "AL_M1"
]
]
]
]
]
;

$policy = (new DynamicPolicyBuilder())
->withAdvancedIdentityProfileRequirements($advancedIdentityProfileJson)
->build();

$dynamicScenario = (new DynamicScenarioBuilder())
->withCallbackEndpoint("/profile")
->withPolicy($policy)
->withSubject((object)[
'subject_id' => "some_subject_id_string"
])
->build();

return view('advanced', [
'title' => 'Advanced Identity Share 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'
]
]
]
]);
}
}
65 changes: 65 additions & 0 deletions examples/profile/resources/views/advanced.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
<!DOCTYPE html>
<html class="yoti-html">

<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<title>{{ $title }}</title>
<link rel="stylesheet" type="text/css" href="assets/css/index.css">
<link href="https://fonts.googleapis.com/css?family=Roboto:400,700" rel="stylesheet">
</head>

<body class="yoti-body">
<main>
<section class="yoti-top-section">
<div class="yoti-logo-section">
<a href="https://www.yoti.com" target="_blank">
<img class="yoti-logo-image" src="assets/images/logo.png" srcset="assets/images/[email protected] 2x" alt="Yoti" />
</a>
</div>

<h1 class="yoti-top-header">{{ $title }}</h1>

<div class="yoti-sdk-integration-section">
<div id="yoti-share-button"></div>
</div>

<div class="yoti-login-or-separator">or</div>

<div class="yoti-login-dialog">
<h2 class="yoti-login-dialog-header">Login with your email:</h2>

<input class="yoti-input" type="text" placeholder="Name" />

<input class="yoti-input" type="text" placeholder="Email address" />

<div class="yoti-login-actions">
<span class="yoti-login-forgot-button">forgot password?</span>

<button class="yoti-login-button">login</button>
</div>
</div>
</section>

<section class="yoti-sponsor-app-section">
<h3 class="yoti-sponsor-app-header">The Yoti app is free to download and use:</h3>

<div class="yoti-store-buttons-section">
<a href="https://itunes.apple.com/us/app/yoti/id983980808?ls=1&mt=8" class="yoti-app-button-link">
<img src="assets/images/app-store-badge.png" srcset="assets/images/[email protected] 2x" alt="Download on the App Store" />
</a>

<a href="https://play.google.com/store/apps/details?id=com.yoti.mobile.android.live" class="yoti-app-button-link">
<img src="assets/images/google-play-badge.png" srcset="assets/images/[email protected] 2x" alt="Yoti" alt="get it on Google Play" />
</a>
</div>
</section>
</main>

<script src="https://www.yoti.com/share/client/"></script>
<script>
window.Yoti.Share.init(@json($buttonConfig, JSON_PRETTY_PRINT));
</script>
</body>

</html>
1 change: 1 addition & 0 deletions examples/profile/routes/web.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,4 @@
Route::get('/dynamic-share', 'DynamicShareController@show');

Route::get('/dbs-check', 'DbsCheckController@show');
Route::get('/advanced-identity', 'AdvancedIdentityController@show');
21 changes: 20 additions & 1 deletion src/ShareUrl/Policy/DynamicPolicy.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,19 +33,26 @@ class DynamicPolicy implements \JsonSerializable
*/
private $identityProfileRequirements;

/**
* @var object|null
*/
private $advancedIdentityProfileRequirements;

/**
* @param \Yoti\ShareUrl\Policy\WantedAttribute[] $wantedAttributes
* Array of attributes to be requested.
* @param int[] $wantedAuthTypes
* Auth types represents the authentication type to be used.
* @param bool $wantedRememberMe
* @param object $identityProfileRequirements
* @param object $advancedIdentityProfileRequirements
*/
public function __construct(
array $wantedAttributes,
array $wantedAuthTypes,
bool $wantedRememberMe = false,
$identityProfileRequirements = null
$identityProfileRequirements = null,
$advancedIdentityProfileRequirements = null
) {
Validation::isArrayOfType($wantedAttributes, [WantedAttribute::class], 'wantedAttributes');
$this->wantedAttributes = $wantedAttributes;
Expand All @@ -55,6 +62,7 @@ public function __construct(

$this->wantedRememberMe = $wantedRememberMe;
$this->identityProfileRequirements = $identityProfileRequirements;
$this->advancedIdentityProfileRequirements = $advancedIdentityProfileRequirements;
}

/**
Expand All @@ -70,6 +78,7 @@ public function jsonSerialize(): stdClass
'wanted_remember_me' => $this->wantedRememberMe,
'wanted_remember_me_optional' => false,
'identity_profile_requirements' => $this->identityProfileRequirements,
'advanced_identity_profile_requirements' => $this->advancedIdentityProfileRequirements,
];
}

Expand All @@ -90,4 +99,14 @@ public function getIdentityProfileRequirements()
{
return $this->identityProfileRequirements;
}

/**
* AdvancedIdentityProfileRequirements requested in the policy
*
* @return object|null
*/
public function getAdvancedIdentityProfileRequirements()
{
return $this->advancedIdentityProfileRequirements;
}
}
20 changes: 19 additions & 1 deletion src/ShareUrl/Policy/DynamicPolicyBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,11 @@ class DynamicPolicyBuilder
*/
private $identityProfileRequirements = null;

/**
* @var object|null
*/
private $advancedIdentityProfileRequirements = null;

/**
* @param \Yoti\ShareUrl\Policy\WantedAttribute $wantedAttribute
*
Expand Down Expand Up @@ -400,6 +405,18 @@ public function withIdentityProfileRequirements($identityProfileRequirements): s
return $this;
}

/**
* Use an Identity Profile Requirement object for the share
*
* @param object $advancedIdentityProfileRequirements
* @return $this
*/
public function withAdvancedIdentityProfileRequirements($advancedIdentityProfileRequirements): self
{
$this->advancedIdentityProfileRequirements = $advancedIdentityProfileRequirements;
return $this;
}

/**
* @return DynamicPolicy
*/
Expand All @@ -409,7 +426,8 @@ public function build(): DynamicPolicy
array_values($this->wantedAttributes),
array_values($this->wantedAuthTypes),
$this->wantedRememberMe,
$this->identityProfileRequirements
$this->identityProfileRequirements,
$this->advancedIdentityProfileRequirements
);
}
}
3 changes: 2 additions & 1 deletion tests/ShareUrl/DynamicScenarioBuilderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,8 @@ public function testBuild()
'wanted_auth_types' => [],
'wanted_remember_me' => false,
'wanted_remember_me_optional' => false,
'identity_profile_requirements' => null
'identity_profile_requirements' => null,
'advanced_identity_profile_requirements' => null
],
'extensions' => [
[
Expand Down
Loading

0 comments on commit f454c03

Please sign in to comment.