-
Notifications
You must be signed in to change notification settings - Fork 21
Expand file tree
/
Copy pathAdvancedIdentityController.php
More file actions
69 lines (61 loc) · 2.26 KB
/
AdvancedIdentityController.php
File metadata and controls
69 lines (61 loc) · 2.26 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
<?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;
class AdvancedIdentityController extends BaseController
{
public function generateSession(DigitalIdentityClient $client)
{
try {
$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 PolicyBuilder())
->withAdvancedIdentityProfileRequirements((object)$advancedIdentityProfileJson)
->build();
$redirectUri = 'https://host/redirect/';
$shareSessionRequest = (new ShareSessionRequestBuilder())
->withPolicy($policy)
->withRedirectUri($redirectUri)
->build();
$session = $client->createShareSession($shareSessionRequest);
return $session->getId();
}
catch (\Throwable $e) {
Log::error($e->getTraceAsString());
throw new BadRequestHttpException($e->getMessage());
}
}
public function show(DigitalIdentityClient $client)
{
try {
return view('advancedidentity', [
'title' => 'Digital Identity(Advanced) Complete Example',
'sdkId' => $client->id
]);
} catch (\Throwable $e) {
Log::error($e->getTraceAsString());
throw new BadRequestHttpException($e->getMessage());
}
}
}