ILIAS  release_10 Revision v10.1-43-ga1241a92c2f
ltiauth.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
22 require_once("../vendor/composer/vendor/autoload.php");
23 
24 
29 if (strtoupper($_SERVER['REQUEST_METHOD']) == 'POST') {
30  $orig = new ArrayObject($_POST);
31  $data = $orig->getArrayCopy();
32 } elseif (strtoupper($_SERVER['REQUEST_METHOD']) == 'GET') {
33  $orig = new ArrayObject($_GET);
34  $data = $orig->getArrayCopy();
35  // early removing client_id from $_GET
36  // otherwise the client_id is interpreted as ILIAS client_id
37  // and client.ini.php will not be found
38  if (isset($_GET['client_id'])) {
39  unset($_GET['client_id']);
40  }
41 } else {
42  header($_SERVER["SERVER_PROTOCOL"] . " 405 Method Not Allowed", true, 405);
44 }
45 
47 
48 global $DIC;
49 
50 $ltiMessageHint = $data['lti_message_hint'];
51 
52 if (empty($ltiMessageHint)) {
53  $DIC->http()->saveResponse(
54  $DIC->http()->response()
55  ->withStatus(400)
56  );
57  try {
58  $DIC->http()->sendResponse();
59  $DIC->http()->close();
60  } catch (\ILIAS\HTTP\Response\Sender\ResponseSendingException $e) {
61  $DIC->http()->close();
62  }
63 }
64 $mh = explode(":", $ltiMessageHint);
66 $ref_id = '';
69 if (count($mh) == 2) { // launch message auth
70  list($ref_id, $client_id) = explode(":", $ltiMessageHint);
71 } else { // contentSelection message auth
72  $isContentSelection = true;
73  list($ref_id, $client_id, $redirect_uri) = explode(":", $ltiMessageHint);
74 }
75 
76 ilSession::set('lti13_login_data', $data);
78  $url = "../../../" . base64_decode($redirect_uri);
79 } else {
80  $url = "../../../goto.php?target=lti_" . $ref_id . "&client_id=" . $client_id;
81 }
82 
83 $DIC->http()->saveResponse(
84  $DIC->http()->response()
85  ->withStatus(302)
86  ->withAddedHeader('Location', $url)
87 );
88 try {
89  $DIC->http()->sendResponse();
90  $DIC->http()->close();
91 } catch (\ILIAS\HTTP\Response\Sender\ResponseSendingException $e) {
92  $DIC->http()->close();
93 }
if(empty($ltiMessageHint)) $mh
Definition: ltiauth.php:64
$redirect_uri
Definition: ltiauth.php:68
Interface Observer Contains several chained tasks and infos about them.
$isContentSelection
Definition: ltiauth.php:65
$_POST['cmd']
Definition: lti.php:27
global $DIC
Definition: ltiauth.php:48
$url
Definition: shib_logout.php:63
static initILIAS()
ilias initialisation
$ref_id
Definition: ltiauth.php:66
$_SERVER['HTTP_HOST']
Definition: raiseError.php:10
$ltiMessageHint
Definition: ltiauth.php:50
$_GET['cmd']
Definition: lti.php:26
$client_id
Definition: ltiauth.php:67
exit
Definition: ltiauth.php:43
header()
expected output: > ILIAS shows the rendered Component.
Definition: header.php:13
static set(string $a_var, $a_val)
Set a value.