ILIAS  release_8 Revision v8.23
ltiauth.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
4 
22 chdir("../../");
23 
28 if (strtoupper($_SERVER['REQUEST_METHOD']) == 'POST') {
29  $orig = new ArrayObject($_POST);
30  $data = $orig->getArrayCopy();
31 } elseif (strtoupper($_SERVER['REQUEST_METHOD']) == 'GET') {
32  $orig = new ArrayObject($_GET);
33  $data = $orig->getArrayCopy();
34  // early removing client_id from $_GET
35  // otherwise the client_id is interpreted as ILIAS client_id
36  // and client.ini.php will not be found
37  if (isset($_GET['client_id'])) {
38  unset($_GET['client_id']);
39  }
40 } else {
41  header($_SERVER["SERVER_PROTOCOL"] . " 405 Method Not Allowed", true, 405);
43 }
44 
45 require_once("Services/Init/classes/class.ilInitialisation.php");
46 
48 
49 global $DIC;
50 
51 $ltiMessageHint = $data['lti_message_hint'];
52 
53 if (empty($ltiMessageHint)) {
54  $DIC->http()->saveResponse(
55  $DIC->http()->response()
56  ->withStatus(400)
57  );
58  try {
59  $DIC->http()->sendResponse();
60  $DIC->http()->close();
61  } catch (\ILIAS\HTTP\Response\Sender\ResponseSendingException $e) {
62  $DIC->http()->close();
63  }
64 }
65 $mh = explode(":", $ltiMessageHint);
67 $ref_id = '';
70 if (count($mh) == 2) { // launch message auth
71  list($ref_id, $client_id) = explode(":", $ltiMessageHint);
72 } else { // contentSelection message auth
73  $isContentSelection = true;
74  list($ref_id, $client_id, $redirect_uri) = explode(":", $ltiMessageHint);
75 }
76 
77 ilSession::set('lti13_login_data', $data);
79  $url = "../../" . base64_decode($redirect_uri);
80 } else {
81  $url = "../../goto.php?target=lti_" . $ref_id . "&client_id=" . $client_id;
82 }
83 
84 $DIC->http()->saveResponse(
85  $DIC->http()->response()
86  ->withStatus(302)
87  ->withAddedHeader('Location', $url)
88 );
89 try {
90  $DIC->http()->sendResponse();
91  $DIC->http()->close();
92 } catch (\ILIAS\HTTP\Response\Sender\ResponseSendingException $e) {
93  $DIC->http()->close();
94 }
if(empty($ltiMessageHint)) $mh
Definition: ltiauth.php:65
$redirect_uri
Definition: ltiauth.php:69
Class ChatMainBarProvider .
$isContentSelection
Definition: ltiauth.php:66
global $DIC
Definition: ltiauth.php:49
static initILIAS()
ilias initialisation
$ref_id
Definition: ltiauth.php:67
$_GET['client_id']
Definition: saml1-acs.php:21
$_SERVER['HTTP_HOST']
Definition: raiseError.php:10
$ltiMessageHint
Definition: ltiauth.php:51
$client_id
Definition: ltiauth.php:68
$url
exit
Definition: ltiauth.php:42
static set(string $a_var, $a_val)
Set a value.