From b2f4bf31f383caba56a9c15a188d7eac39b55619 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sa=C3=BAl=20D=C3=ADaz?= Date: Thu, 8 Oct 2026 13:38:30 +0200 Subject: [PATCH] [LTI] fix: keep LTI launches working with celtic/lti 5.4.4 and later --- .../class.ilAuthProviderLTI.php | 2 +- .../class.ilLTIExitException.php | 35 ++++++++++++++++ .../InternalProvider/class.ilLTITool.php | 40 ++++++++++++++++++- 3 files changed, 74 insertions(+), 3 deletions(-) create mode 100644 components/ILIAS/LTIProvider/classes/InternalProvider/class.ilLTIExitException.php diff --git a/components/ILIAS/LTIProvider/classes/InternalProvider/class.ilAuthProviderLTI.php b/components/ILIAS/LTIProvider/classes/InternalProvider/class.ilAuthProviderLTI.php index 46903c538604..99a2ee228539 100644 --- a/components/ILIAS/LTIProvider/classes/InternalProvider/class.ilAuthProviderLTI.php +++ b/components/ILIAS/LTIProvider/classes/InternalProvider/class.ilAuthProviderLTI.php @@ -255,7 +255,7 @@ public function doAuthentication(\ilAuthStatus $status): bool $lti_provider->rsaKey = $pk['key']; $lti_provider->kid = $pk['kid']; $lti_provider->signatureMethod = 'RS256'; - $lti_provider->handleRequest(); + $lti_provider->processRequest(); $this->provider = $lti_provider; $this->messageParameters = $this->provider->getMessageParameters(); diff --git a/components/ILIAS/LTIProvider/classes/InternalProvider/class.ilLTIExitException.php b/components/ILIAS/LTIProvider/classes/InternalProvider/class.ilLTIExitException.php new file mode 100644 index 000000000000..81c72f0fb5be --- /dev/null +++ b/components/ILIAS/LTIProvider/classes/InternalProvider/class.ilLTIExitException.php @@ -0,0 +1,35 @@ +onExitExceptionClass = ilLTIExitException::class; + + try { + $this->handleRequest(); + } catch (ilLTIExitException $e) { + $this->sendPendingResponse(); + } + } + + /** + * Send whatever the LTI library prepared for the platform before it tried to end the request. + * + * A redirect back to the platform carries an error message, an output body is either an error + * page or one of the self submitting forms used for the browser storage and cookie checks. A + * successfully processed launch leaves both of them empty, which is the only case where the + * control flow returns to ILIAS. + */ + private function sendPendingResponse(): void + { + if (!is_null($this->redirectUrl)) { + Util::redirect($this->redirectUrl); + } + + if (!is_null($this->output)) { + echo $this->output; + exit; + } } }