diff --git a/components/ILIAS/LTIConsumer/classes/class.ilLTIConsumerContentGUI.php b/components/ILIAS/LTIConsumer/classes/class.ilLTIConsumerContentGUI.php index 0589dee06506..99db16e6aa3f 100755 --- a/components/ILIAS/LTIConsumer/classes/class.ilLTIConsumerContentGUI.php +++ b/components/ILIAS/LTIConsumer/classes/class.ilLTIConsumerContentGUI.php @@ -32,6 +32,26 @@ class ilLTIConsumerContentGUI public const CMD_LAUNCH = 'launch'; public const CMD_SHOW_EMBEDDED = 'showEmbedded'; + /** + * Query parameter that carries the authentication request of the tool from ltiauth.php to the launch, + * instead of the session: a parallel request of the same session writing the session back later would + * remove it again, e.g. the asynchronous requests of the main bar while an embedded launch is running. + */ + public const LTI13_LOGIN_PARAM = 'lti13_login'; + + private const LTI13_LOGIN_KEYS = [ + 'scope', + 'response_type', + 'client_id', + 'redirect_uri', + 'login_hint', + 'lti_message_hint', + 'state', + 'response_mode', + 'nonce', + 'prompt' + ]; + protected ilObjLTIConsumer $object; protected ilCmiXapiUser $cmixUser; @@ -84,7 +104,8 @@ protected function launch(): void } } else { - if ($this->object->isLaunchMethodEmbedded() && (ilSession::get('lti13_login_data') == null)) { + $loginData = $this->getLTI13LoginData(); + if ($this->object->isLaunchMethodEmbedded() && $loginData === null) { $tpl = new ilTemplate('tpl.lti_content.html', true, true, 'components/ILIAS/LTIConsumer'); $tpl->setVariable("EMBEDDED_IFRAME_SRC", $this->dic->ctrl()->getLinkTarget( $this, @@ -92,8 +113,8 @@ protected function launch(): void )); $this->dic->ui()->mainTemplate()->setContent($tpl->get()); } else { - if (ilSession::get('lti13_login_data') != null) { - $form = $this->getLoginLTI13Form(); + if ($loginData !== null) { + $form = $this->getLoginLTI13Form($loginData); if ($form == null) { // $this->dic->ui()->mainTemplate()->setOnScreenMessage('failure', 'initialLogin Error: ' . $err, true); $this->dic->ui()->mainTemplate()->setOnScreenMessage('failure', 'initialLogin Error: ', true); @@ -110,10 +131,11 @@ protected function launch(): void } } - protected function getLoginLTI13Form(): ?string + protected function getLoginLTI13Form(array $loginData): ?string { - $loginData = ilSession::get('lti13_login_data'); - ilSession::clear('lti13_login_data'); + if (!$this->dic->access()->checkAccess('read', '', $this->object->getRefId())) { + return null; + } $err = $this->validateLTI13InitalLogin($loginData); if ($err !== null) { return null; @@ -123,7 +145,6 @@ protected function getLoginLTI13Form(): ?string if (isset($loginData['state'])) { $params['state'] = $loginData['state']; } - ilSession::clear('lti_message_hint'); $r = '