ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ltiauth.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22require_once("../vendor/composer/vendor/autoload.php");
23
24
29if (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
48global $DIC;
49
50$ltiMessageHint = $data['lti_message_hint'];
51
52if (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);
69if (count($mh) == 2) { // launch message auth
70 list($ref_id, $client_id) = explode(":", $ltiMessageHint);
71} else { // contentSelection message auth
73 list($ref_id, $client_id, $redirect_uri) = explode(":", $ltiMessageHint);
74}
75
76ilSession::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);
88try {
89 $DIC->http()->sendResponse();
90 $DIC->http()->close();
91} catch (\ILIAS\HTTP\Response\Sender\ResponseSendingException $e) {
92 $DIC->http()->close();
93}
static initILIAS()
ilias initialisation
static set(string $a_var, $a_val)
Set a value.
$_GET['cmd']
Definition: lti.php:26
$_POST['cmd']
Definition: lti.php:27
$redirect_uri
Definition: ltiauth.php:68
$client_id
Definition: ltiauth.php:67
$isContentSelection
Definition: ltiauth.php:65
global $DIC
Definition: ltiauth.php:48
exit
Definition: ltiauth.php:43
if(empty($ltiMessageHint)) $mh
Definition: ltiauth.php:64
$ltiMessageHint
Definition: ltiauth.php:50
$ref_id
Definition: ltiauth.php:66
Interface Observer \BackgroundTasks Contains several chained tasks and infos about them.
$_SERVER['HTTP_HOST']
Definition: raiseError.php:26
$url
Definition: shib_logout.php:68