Skip to content

Commit

Permalink
LTI-XXX: patch for searching the right tool when the launch is starting
Browse files Browse the repository at this point in the history
  • Loading branch information
jfederico committed Jun 19, 2024
1 parent b9efa0e commit 7489222
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 9 deletions.
5 changes: 1 addition & 4 deletions app/controllers/concerns/open_id_authenticator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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?
Expand Down
3 changes: 2 additions & 1 deletion app/controllers/concerns/platform_validator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {})
Expand Down
7 changes: 3 additions & 4 deletions app/controllers/message_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit 7489222

Please sign in to comment.