From a834a126729f09d972bc04021f210c8c46fdab85 Mon Sep 17 00:00:00 2001 From: FElliger Date: Mon, 20 May 2024 21:05:23 +0200 Subject: [PATCH 1/3] Allow using RSA key when saving LTI Content Selection Previously, the LTI forms allowed storing a static public key, but the code for processing the content selection response only looked for the keyset URL. With this change, both ways are supported, depending on which key type is stored. --- .../classes/class.ilObjLTIConsumerGUI.php | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/Modules/LTIConsumer/classes/class.ilObjLTIConsumerGUI.php b/Modules/LTIConsumer/classes/class.ilObjLTIConsumerGUI.php index 5c829c5a21b1..276a361c750e 100755 --- a/Modules/LTIConsumer/classes/class.ilObjLTIConsumerGUI.php +++ b/Modules/LTIConsumer/classes/class.ilObjLTIConsumerGUI.php @@ -477,11 +477,15 @@ public function cancelContentSelection(): void public function saveContentSelection(ilLTIConsumeProvider $provider, string $token): void { - //ToDo: fetch with file_get_contents ok? needs caching? - $jwks = file_get_contents($provider->getPublicKeyset()); - //ToDo: Errorhandling - $keyset = json_decode($jwks, true); - $keys = Firebase\JWT\JWK::parseKeySet($keyset); + if ($provider->getKeyType() == 'RSA_KEY') { + $key = $provider->getPublicKey(); + $keys = new Firebase\JWT\Key($key, "RS256"); + } else { + $jwks = file_get_contents($provider->getPublicKeyset()); + //ToDo: Errorhandling + $keyset = json_decode($jwks, true); + $keys = Firebase\JWT\JWK::parseKeySet($keyset); + } $data = Firebase\JWT\JWT::decode($token, $keys); //ilObjLTIConsumer::getLogger()->debug(var_export($data,TRUE)); $refId = $this->getRequestValue('ref_id'); From 23d6ef0f97c74021dce85ad61480895719da4e0f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sa=C3=BAl=20D=C3=ADaz?= <62429591+Saaweel@users.noreply.github.com> Date: Mon, 11 Nov 2024 12:15:57 +0100 Subject: [PATCH 2/3] Update class.ilObjLTIConsumerGUI.php --- Modules/LTIConsumer/classes/class.ilObjLTIConsumerGUI.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Modules/LTIConsumer/classes/class.ilObjLTIConsumerGUI.php b/Modules/LTIConsumer/classes/class.ilObjLTIConsumerGUI.php index 276a361c750e..1f41b62d2da5 100755 --- a/Modules/LTIConsumer/classes/class.ilObjLTIConsumerGUI.php +++ b/Modules/LTIConsumer/classes/class.ilObjLTIConsumerGUI.php @@ -1,7 +1,5 @@ From a75650ca60fa306697cbae500331b7f42064ab98 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sa=C3=BAl=20D=C3=ADaz?= <62429591+Saaweel@users.noreply.github.com> Date: Mon, 11 Nov 2024 14:58:34 +0100 Subject: [PATCH 3/3] Update class.ilObjLTIConsumerGUI.php --- Modules/LTIConsumer/classes/class.ilObjLTIConsumerGUI.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Modules/LTIConsumer/classes/class.ilObjLTIConsumerGUI.php b/Modules/LTIConsumer/classes/class.ilObjLTIConsumerGUI.php index 1f41b62d2da5..63264bd6fb4a 100755 --- a/Modules/LTIConsumer/classes/class.ilObjLTIConsumerGUI.php +++ b/Modules/LTIConsumer/classes/class.ilObjLTIConsumerGUI.php @@ -343,7 +343,7 @@ public function showToolConfig(): void $provider_id = $this->getRequestValue("provider_id"); $DIC->ctrl()->setParameter($this, "provider_id", $provider_id); $DIC->language()->loadLanguageModule($new_type); - $form = $this->initShowToolConfig($new_type, (int)$provider_id); + $form = $this->initShowToolConfig($new_type, (int) $provider_id); $DIC->ui()->mainTemplate()->setContent($form->getHTML()); } @@ -360,7 +360,7 @@ public function saveDynReg(): void $DIC->language()->loadLanguageModule($new_type); ilSession::clear('lti_dynamic_registration_client_id'); ilSession::clear('lti_dynamic_registration_custom_params'); - $form = $this->initShowToolConfig($new_type, (int)$provider_id); + $form = $this->initShowToolConfig($new_type, (int) $provider_id); $form->setValuesByPost(); if ($form->checkInput()) { // update only overridable fields $provider = $form->getProvider(); @@ -854,7 +854,7 @@ protected function checkContentSelection(): void $newType = $this->getRequestValue('new_type'); $refId = $this->getRequestValue('ref_id'); if ($providerId !== null && $newType == 'lti' && $refId != null) { - $provider = new ilLTIConsumeProvider((int)$providerId); + $provider = new ilLTIConsumeProvider((int) $providerId); // check if post variables from contentSelectionResponse if ($DIC->http()->wrapper()->post()->has('JWT')) { // ToDo: