From 74892229ed629d717626fbb8a7bebbe15ee51735 Mon Sep 17 00:00:00 2001 From: jfederico Date: Wed, 19 Jun 2024 17:12:11 -0400 Subject: [PATCH 1/3] LTI-XXX: patch for searching the right tool when the launch is starting --- app/controllers/concerns/open_id_authenticator.rb | 5 +---- app/controllers/concerns/platform_validator.rb | 3 ++- app/controllers/message_controller.rb | 7 +++---- 3 files changed, 6 insertions(+), 9 deletions(-) diff --git a/app/controllers/concerns/open_id_authenticator.rb b/app/controllers/concerns/open_id_authenticator.rb index 349898f1..be14f96a 100644 --- a/app/controllers/concerns/open_id_authenticator.rb +++ b/app/controllers/concerns/open_id_authenticator.rb @@ -71,10 +71,7 @@ def validate_nonce(jwt_body) def validate_registration(jwt_body) issuer = jwt_body['iss'] - options = {} - options['client_id'] = jwt_body['aud'] - - registration = RailsLti2Provider::Tool.find_by_issuer(issuer, options) + registration = RailsLti2Provider::Tool.find_by_issuer(issuer, { 'client_id' => jwt_body['aud'] }) raise CustomError, :not_registered if registration.nil? raise CustomError, :disabled if registration.disabled? diff --git a/app/controllers/concerns/platform_validator.rb b/app/controllers/concerns/platform_validator.rb index 25692108..4ab57d1e 100644 --- a/app/controllers/concerns/platform_validator.rb +++ b/app/controllers/concerns/platform_validator.rb @@ -27,7 +27,8 @@ def lti_secret(key, _options = {}) # LTI 1.3 def lti_registration_exists?(iss, options = {}) - RailsLti2Provider::Tool.find_by_issuer(iss, options).present? + registration = lti_registration(iss, options) + registration.present? end def lti_registration_params(iss, options = {}) diff --git a/app/controllers/message_controller.rb b/app/controllers/message_controller.rb index 1c8d6c39..c1cbc3f3 100644 --- a/app/controllers/message_controller.rb +++ b/app/controllers/message_controller.rb @@ -226,12 +226,11 @@ def process_openid_message @jwt_body = jwt[:body] logger.debug("JWT Body: #{@jwt_body}") - tool = lti_registration(@jwt_body['iss']) + tool = RailsLti2Provider::Tool.find_by(uuid: @jwt_body['iss'], shared_secret: @jwt_body['aud']) # Cleanups the lti_launches table from old launches. tool.lti_launches.where('created_at < ?', 1.day.ago).delete_all - nonce = @jwt_body['nonce'] - message = @jwt_body.merge(@jwt_header) - @lti_launch = tool.lti_launches.create(nonce: nonce, message: message) + # Create a new lti_launch. + @lti_launch = tool.lti_launches.create(nonce: @jwt_body['nonce'], message: @jwt_body.merge(@jwt_header)) ############################# # Monkey patch for Canvas: validate kid in registration, if not present, add the one in the jwt header. From f6a0c9328c24d6625ab8ea75cc05aa2bc2a75e22 Mon Sep 17 00:00:00 2001 From: Jesus Federico Date: Wed, 19 Jun 2024 17:40:12 -0400 Subject: [PATCH 2/3] Update open_id_authenticator.rb --- app/controllers/concerns/open_id_authenticator.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/app/controllers/concerns/open_id_authenticator.rb b/app/controllers/concerns/open_id_authenticator.rb index be14f96a..bc586be5 100644 --- a/app/controllers/concerns/open_id_authenticator.rb +++ b/app/controllers/concerns/open_id_authenticator.rb @@ -16,6 +16,7 @@ # You should have received a copy of the GNU Lesser General Public License along # with BigBlueButton; if not, see . + require 'open-uri' module OpenIdAuthenticator From 06bfbb3ffa5512de2cbfb620c232e415bd78322f Mon Sep 17 00:00:00 2001 From: Jesus Federico Date: Wed, 19 Jun 2024 17:40:26 -0400 Subject: [PATCH 3/3] Update open_id_authenticator.rb --- app/controllers/concerns/open_id_authenticator.rb | 1 - 1 file changed, 1 deletion(-) diff --git a/app/controllers/concerns/open_id_authenticator.rb b/app/controllers/concerns/open_id_authenticator.rb index bc586be5..be14f96a 100644 --- a/app/controllers/concerns/open_id_authenticator.rb +++ b/app/controllers/concerns/open_id_authenticator.rb @@ -16,7 +16,6 @@ # You should have received a copy of the GNU Lesser General Public License along # with BigBlueButton; if not, see . - require 'open-uri' module OpenIdAuthenticator