ILIAS  release_8 Revision v8.24
ltiauth.php
Go to the documentation of this file.
1<?php
2
3declare(strict_types=1);
4
22chdir("../../");
23
28if (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
45require_once("Services/Init/classes/class.ilInitialisation.php");
46
48
49global $DIC;
50
51$ltiMessageHint = $data['lti_message_hint'];
52
53if (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);
70if (count($mh) == 2) { // launch message auth
71 list($ref_id, $client_id) = explode(":", $ltiMessageHint);
72} else { // contentSelection message auth
74 list($ref_id, $client_id, $redirect_uri) = explode(":", $ltiMessageHint);
75}
76
77ilSession::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);
89try {
90 $DIC->http()->sendResponse();
91 $DIC->http()->close();
92} catch (\ILIAS\HTTP\Response\Sender\ResponseSendingException $e) {
93 $DIC->http()->close();
94}
static initILIAS()
ilias initialisation
static set(string $a_var, $a_val)
Set a value.
$redirect_uri
Definition: ltiauth.php:69
$client_id
Definition: ltiauth.php:68
$isContentSelection
Definition: ltiauth.php:66
global $DIC
Definition: ltiauth.php:49
exit
Definition: ltiauth.php:42
if(empty($ltiMessageHint)) $mh
Definition: ltiauth.php:65
$ltiMessageHint
Definition: ltiauth.php:51
$ref_id
Definition: ltiauth.php:67
Class ChatMainBarProvider \MainMenu\Provider.
$url
$_SERVER['HTTP_HOST']
Definition: raiseError.php:10
$_GET['client_id']
Definition: saml1-acs.php:21