diff --git a/Gemfile b/Gemfile index 75ab5ee6..56885cf5 100644 --- a/Gemfile +++ b/Gemfile @@ -41,7 +41,7 @@ gem 'redis', '~> 4.2' gem 'jwt', '~> 2.2.2' gem 'oauth', '~> 0.5.1' -gem 'doorkeeper', '~> 5.5.0' +gem 'doorkeeper', '~> 5.4.0' gem 'repost', '~> 0.3.8' gem 'lodash-rails' diff --git a/Gemfile.lock b/Gemfile.lock index f7cdb055..6bf75fb3 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -136,7 +136,7 @@ GEM docile (1.4.0) domain_name (0.5.20190701) unf (>= 0.0.5, < 1.0.0) - doorkeeper (5.5.4) + doorkeeper (5.4.0) railties (>= 5) dotenv (2.8.1) dotenv-rails (2.8.1) @@ -426,7 +426,7 @@ DEPENDENCIES byebug coffee-rails (~> 5.0, >= 5.0.0) coveralls - doorkeeper (~> 5.5.0) + doorkeeper (~> 5.4.0) dotenv-rails faraday font-awesome-sass (~> 5.9.0) diff --git a/lib/bbb_lti_broker/helpers.rb b/lib/bbb_lti_broker/helpers.rb index e1cab443..dc64a708 100644 --- a/lib/bbb_lti_broker/helpers.rb +++ b/lib/bbb_lti_broker/helpers.rb @@ -67,7 +67,7 @@ def standarized_message(message_json) message['resource_link_description'] = message['unknown_params']['https://purl.imsglobal.org/spec/lti/claim/resource_link']['description'] message['launch_presentation_locale'] = message['unknown_params']['https://purl.imsglobal.org/spec/lti/claim/launch_presentation']['locale'] end - message.to_json + custom_overrides(message).to_json end def user_params(tc_instance_guid, params) @@ -86,5 +86,26 @@ def user_params(tc_instance_guid, params) last_accessed_at: Time.current, } end + + ## + # Overrides core parameters with custom parameters when following certain pattern. + # + # Core parameters may have to be overriden in order to make the applications behave differently + # for that, the LTI link in the tool consumer would need to include a custom parameter in the form: + # + # custom_resource_link_id=static:"some value" -> resource_link_id="some value" + # custom_resource_link_id=param:contenxt_id -> resource_link_id= + # custom_resource_link_id="another value" -> resource_link_id= + # + def custom_overrides(message) + custom_params = message['custom_params'].to_h + custom_params.each do |key, value| + custom_param = key.delete_prefix('custom_') + pattern = value.split(':') + message[custom_param] = pattern[1] if pattern[0] == 'static' + message[custom_param] = message[pattern[1]] if pattern[0] == 'param' + end + message + end end end diff --git a/lib/tasks/db_registration.rake b/lib/tasks/db_registration.rake index d50ea016..7079f347 100644 --- a/lib/tasks/db_registration.rake +++ b/lib/tasks/db_registration.rake @@ -63,7 +63,7 @@ namespace :db do ) puts(jwk) if args[:type] == 'jwk' - puts(public_key.to_s) if args[:type] == 'key' + puts(public_key) if args[:type] == 'key' rescue StandardError => e puts(e.backtrace) exit(1) @@ -139,7 +139,7 @@ namespace :db do registration.update(tool_settings: tool_settings.to_json, shared_secret: client_id) puts(jwk) if args[:type] == 'jwk' - puts(public_key.to_s) if args[:type] == 'key' + puts(public_key) if args[:type] == 'key' end desc 'Lists the Registration Configuration URLs need to register an app' diff --git a/spec/rails_helper.rb b/spec/rails_helper.rb index b6443c68..d45b11e9 100644 --- a/spec/rails_helper.rb +++ b/spec/rails_helper.rb @@ -55,7 +55,7 @@ end RSpec.configure do |config| # Remove this line if you're not using ActiveRecord or ActiveRecord fixtures - config.fixture_path = "#{::Rails.root}/spec/fixtures" + config.fixture_path = Rails.root.join('spec/fixtures') # If you're not using ActiveRecord, or you'd prefer not to run each of your # examples within a transaction, remove the following line or assign false