From 2dbe183d7bdded42cf3a2dba521d5d033e1120a3 Mon Sep 17 00:00:00 2001 From: "Daniel Cazalla (ZallaxDev)" <86362063+ZallaxDev@users.noreply.github.com> Date: Wed, 4 Dec 2024 11:07:21 +0100 Subject: [PATCH] LTI: Authentication check for registering new LTI providers and HTML escaping The LTIConsumer creation entry point has been modified to add a user check and an unused get method check has been removed. Added htmlspecialchars to ilObjLTIConsumerProviderList::getTableDataUsedBy in the title and description of the table providers. Moved strict_types to avoid error in copyright check. --- .../classes/class.ilLTIConsumeProviderList.php | 8 ++++---- components/ILIAS/LTIConsumer/ltiregstart.php | 7 ++----- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/components/ILIAS/LTIConsumer/classes/class.ilLTIConsumeProviderList.php b/components/ILIAS/LTIConsumer/classes/class.ilLTIConsumeProviderList.php index d7320a65df4e..1da991a39aa9 100755 --- a/components/ILIAS/LTIConsumer/classes/class.ilLTIConsumeProviderList.php +++ b/components/ILIAS/LTIConsumer/classes/class.ilLTIConsumeProviderList.php @@ -1,7 +1,5 @@ getId(); - $tblRow['title'] = $provider->getTitle(); - $tblRow['description'] = $provider->getDescription(); + $tblRow['title'] = htmlspecialchars($provider->getTitle()); + $tblRow['description'] = htmlspecialchars($provider->getDescription()); $tblRow['category'] = $provider->getCategory(); $tblRow['keywords'] = $this->getKeywordsFormatted($provider->getKeywordsArray()); $tblRow['outcome'] = $provider->getHasOutcome(); diff --git a/components/ILIAS/LTIConsumer/ltiregstart.php b/components/ILIAS/LTIConsumer/ltiregstart.php index e6271689e1ed..2e1022d07ec1 100755 --- a/components/ILIAS/LTIConsumer/ltiregstart.php +++ b/components/ILIAS/LTIConsumer/ltiregstart.php @@ -24,11 +24,8 @@ ilInitialisation::initILIAS(); global $DIC; -if (strtoupper($DIC->http()->request()->getMethod()) !== "GET") { - $DIC->http()->saveResponse( - $DIC->http()->response() - ->withStatus(400) - ); +if (!$DIC->user()->getId() || $DIC->user()->getId() === ANONYMOUS_USER_ID) { + ilObjLTIConsumer::sendResponseError(401, "unauthorized"); } $params = $DIC->http()->wrapper()->query();