ILIAS  release_8 Revision v8.24
ltiregstart.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22chdir("../../");
23
24require_once("Services/Init/classes/class.ilInitialisation.php");
25
27global $DIC;
28
30 ilObjLTIConsumer::sendResponseError(401, "unauthorized");
31}
32
33$params = $DIC->http()->wrapper()->query();
34
35$url = '';
37
38if ($params->has('url')) {
39 $url = $params->retrieve('url', $DIC->refinery()->kindlyTo()->string());
40
41 if (empty($_POST["url"]) || $_POST["url"] != $url) {
42 ilObjLTIConsumer::sendResponseError(400, "url parameter in request does not match url parameter in post");
43 }
44} else {
45 ilObjLTIConsumer::sendResponseError(400, "missing required url parameter in request");
46}
47// optional
48if ($params->has('typeid')) {
49 $typeId = $params->retrieve('typeid', $DIC->refinery()->kindlyTo()->listOf($DIC->refinery()->kindlyTo()->string()));
50}
51// create jwt token
54if (!empty($typeId)) {
55 // In the context of an update, the aud is the id of the type.
56 $aud = strval($typeId);
58}
59try {
60 $now = time();
62 "sub" => $DIC->user()->getId(),
63 "aud" => $clientId,
64 "scope" => $scope,
65 "iat" => $now,
66 "exp" => $now + 3600
67 ];
70 if ($params->has('custom_params')) {
71 $customParams = urldecode($params->retrieve('custom_params', $DIC->refinery()->kindlyTo()->string()));
72 ilSession::set('lti_dynamic_registration_custom_params', $customParams);
73 }
74 ilSession::set('lti_dynamic_registration_client_id', $clientId);
75 header("Location: " . $url . "&openid_configuration=" . urlencode(ilObjLTIConsumer::getOpenidConfigUrl()) . "&registration_token=" . $regToken);
76} catch (Exception $exception) {
77 ilObjLTIConsumer::sendResponseError(500, "error in ltiregstart.php: " . $exception->getMessage());
78}
static encode(array $payload, $key, string $alg, string $keyId=null, array $head=null)
Converts and signs a PHP array into a JWT string.
Definition: JWT.php:199
static initILIAS()
ilias initialisation
static sendResponseError(int $code, string $message, $log=true)
static set(string $a_var, $a_val)
Set a value.
$token
Definition: ltiregstart.php:61
$privateKey
Definition: ltiregstart.php:68
$regToken
Definition: ltiregstart.php:69
if(! $DIC->user() ->getId()||!ilLTIConsumerAccess::hasCustomProviderCreationAccess()) $params
Definition: ltiregstart.php:33
$scope
Definition: ltiregstart.php:53
global $DIC
Definition: ltiregstart.php:27
$typeId
Definition: ltiregstart.php:36
$url
Definition: ltiregstart.php:35
if($params->has('typeid')) $clientId
Definition: ltiregstart.php:52