qalam_lti_provider_engine 1.1.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (57) hide show
  1. checksums.yaml +7 -0
  2. data/MIT-LICENSE +20 -0
  3. data/README.md +146 -0
  4. data/Rakefile +28 -0
  5. data/app/controllers/lti_provider/application_controller.rb +5 -0
  6. data/app/controllers/lti_provider/lti_application_controller.rb +5 -0
  7. data/app/controllers/lti_provider/lti_controller.rb +73 -0
  8. data/app/models/lti_provider/launch.rb +106 -0
  9. data/app/views/layouts/lti_provider/application.html.erb +12 -0
  10. data/app/views/lti_provider/lti/cookie_test.html.erb +4 -0
  11. data/config/lti.yml.example +13 -0
  12. data/config/lti_xml.yml.example +22 -0
  13. data/config/routes.rb +6 -0
  14. data/db/migrate/20130319050003_create_lti_provider_launches.rb +11 -0
  15. data/lib/lti_provider/config.rb +3 -0
  16. data/lib/lti_provider/engine.rb +19 -0
  17. data/lib/lti_provider/lti_application.rb +60 -0
  18. data/lib/lti_provider/lti_config.rb +30 -0
  19. data/lib/lti_provider/lti_xml_config.rb +23 -0
  20. data/lib/lti_provider/version.rb +3 -0
  21. data/lib/lti_provider/xml_config.rb +3 -0
  22. data/lib/lti_provider.rb +20 -0
  23. data/lib/tasks/lti_provider_tasks.rake +4 -0
  24. data/spec/controllers/lti_provider/lti_controller_spec.rb +147 -0
  25. data/spec/dummy/Rakefile +7 -0
  26. data/spec/dummy/app/controllers/application_controller.rb +5 -0
  27. data/spec/dummy/app/controllers/welcome_controller.rb +5 -0
  28. data/spec/dummy/config/application.rb +57 -0
  29. data/spec/dummy/config/boot.rb +10 -0
  30. data/spec/dummy/config/cucumber.yml +8 -0
  31. data/spec/dummy/config/database.yml +25 -0
  32. data/spec/dummy/config/environment.rb +5 -0
  33. data/spec/dummy/config/environments/development.rb +29 -0
  34. data/spec/dummy/config/environments/production.rb +65 -0
  35. data/spec/dummy/config/environments/test.rb +33 -0
  36. data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
  37. data/spec/dummy/config/initializers/inflections.rb +15 -0
  38. data/spec/dummy/config/initializers/mime_types.rb +5 -0
  39. data/spec/dummy/config/initializers/secret_token.rb +7 -0
  40. data/spec/dummy/config/initializers/session_store.rb +8 -0
  41. data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
  42. data/spec/dummy/config/locales/en.yml +5 -0
  43. data/spec/dummy/config/lti.yml +13 -0
  44. data/spec/dummy/config/lti_xml.yml +24 -0
  45. data/spec/dummy/config/routes.rb +4 -0
  46. data/spec/dummy/config.ru +4 -0
  47. data/spec/dummy/db/migrate/20130319050206_create_lti_provider_launches.lti_provider.rb +12 -0
  48. data/spec/dummy/db/schema.rb +24 -0
  49. data/spec/dummy/public/404.html +26 -0
  50. data/spec/dummy/public/422.html +26 -0
  51. data/spec/dummy/public/500.html +25 -0
  52. data/spec/dummy/public/favicon.ico +0 -0
  53. data/spec/dummy/public/robots.txt +5 -0
  54. data/spec/dummy/script/rails +6 -0
  55. data/spec/models/lti_provider/launch_spec.rb +70 -0
  56. data/spec/spec_helper.rb +57 -0
  57. metadata +353 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 966db98bfcaa29cbf05e8b3b38f270f50cc4ea27480a2245dd08804f09f502a8
4
+ data.tar.gz: 2d7be0649b8c6cf2b2e34bf41224de7e31896255e58969adf109c78f9f108add
5
+ SHA512:
6
+ metadata.gz: c52b467a447ca10b21669f601caf1e31bdbd9e2e00f6cd5f2f094d8424da8c706c93ca17d476797200cf46b3cd8da7cab66cfad9a0dd312a311e1d0147da213e
7
+ data.tar.gz: 5a2eb1b5611808ecc4a896c2e6e11a0e491ae3831fc6c74e0eb09bfd3aaa789c002c974be00d5f716beecc63f5cb00c143fdfd4041e6828081a6b458c0999cbe
data/MIT-LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright 2012 - 2014 Instructure, Inc.
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,146 @@
1
+ # LtiProvider
2
+
3
+ LtiProvider is a mountable engine for handling the LTI launch and exposing LTI
4
+ parameters in your rails app.
5
+
6
+ ## Installation
7
+
8
+ Add the gem to your `Gemfile` with the following line, and then `bundle install`
9
+
10
+ ```ruby
11
+ gem 'qalam_lti_provider_engine', :require => 'lti_provider'
12
+ ```
13
+
14
+ Then, mount the engine to your app by adding this line to your `routes.rb` file
15
+
16
+ ```ruby
17
+ mount LtiProvider::Engine => "/"
18
+ ```
19
+
20
+ Next, include the engine in your `ApplicationController`
21
+
22
+ ```ruby
23
+ class ApplicationController < ActionController::Base
24
+ include LtiProvider::LtiApplication
25
+
26
+ ...
27
+ end
28
+ ```
29
+
30
+ After that, create `lti.yml` and `lti_xml.yml` files in your `config/` folder that looks something
31
+ like this:
32
+
33
+ **lti.yml**
34
+
35
+ ```yml
36
+ default: &default
37
+ key: your_key
38
+ secret: your_secret
39
+ require_canvas: true
40
+
41
+ development:
42
+ <<: *default
43
+
44
+ test:
45
+ <<: *default
46
+
47
+ production:
48
+ <<: *default
49
+ ```
50
+
51
+ You'll need the values of `key` and `secret` when you configure your lti app on
52
+ the tool consumer side.
53
+
54
+ **lti_xml.yml**
55
+
56
+ ```yml
57
+ default: &default
58
+ tool_title: 'Dummy App'
59
+ tool_description: 'A very handy dummy application for testing LtiProvider engine integration.'
60
+ tool_id: 'dummy'
61
+ privacy_level: 'public'
62
+ account_navigation:
63
+ text: 'Dummy'
64
+ visibility: 'admins'
65
+ course_navigation:
66
+ text: 'Dummy'
67
+ visibility: 'admins'
68
+
69
+ development:
70
+ <<: *default
71
+
72
+ test:
73
+ <<: *default
74
+
75
+ production:
76
+ <<: *default
77
+ ```
78
+
79
+ These values are used in the `/configure.xml` endpoint.
80
+
81
+ Finally, run migrations:
82
+
83
+ ```bash
84
+ bundle install
85
+ bundle exec rake railties:install:migrations
86
+ bundle exec rake db:migrate
87
+ ```
88
+
89
+ This will create the `lti_provider_launches` table which stores parameters
90
+ temporarily through a cookie test redirect. It is transient data. It can be
91
+ accessed from your main application as LtiProvider::Launch
92
+
93
+ ## Usage
94
+
95
+ The engine exposes a few urls from the mount point:
96
+
97
+ * `/cookie_test`
98
+ * `/consume_launch`
99
+ * `/launch`
100
+ * `/configure.xml`
101
+
102
+ Mostly, you don't have to worry about these, they are used to route through the
103
+ lti launch. However, `/configure.xml` can be useful in configuring the app on
104
+ the tool consumer side. Right now it is hardcoded to 'Course Navigation' and
105
+ 'Account navigation' apps.
106
+
107
+ The engine sets up a global `before_filter`, requiring your app to be launched
108
+ through lti. It handles receiving the request, verifying it, and exposing
109
+ certain config variables sent with the launch parameters. Specifically, it
110
+ exposes the following methods to your controllers:
111
+
112
+ * `canvas_url`
113
+ * `user_id`
114
+ * `current_course_id`
115
+ * `tool_consumer_instance_guid`
116
+ * `current_account_id`
117
+ * `course_launch?`
118
+ * `account_launch?`
119
+ * `user_roles`
120
+
121
+ ## Configuring the Tool Consumer
122
+
123
+ You will need `key` and `secret` from your `lti.yml` file, and you can find
124
+ configuration xml (or at least a starting point) at
125
+ `<engine-mount-point>/configure.xml`
126
+
127
+ ## Example
128
+
129
+ You can see and interact with an example of an app using this engine by looking
130
+ at `spec/dummy`. This is a full rails app which integrates the gem and has
131
+ a simple index page that says 'Hello LTI' if the app is launched through LTI.
132
+
133
+ ## About LTI
134
+
135
+ Interested in learning more about LTI? Here are some links to get you started:
136
+
137
+ * [Introduction to LTI](http://www.imsglobal.org/toolsinteroperability2.cfm)
138
+ * [1.1.1 Implementation Guide](http://www.imsglobal.org/LTI/v1p1p1/ltiIMGv1p1p1.html)
139
+
140
+ ## Contributing
141
+
142
+ 1. Fork it
143
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
144
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
145
+ 4. Push to the branch (`git push origin my-new-feature`)
146
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,28 @@
1
+ #!/usr/bin/env rake
2
+ begin
3
+ require 'bundler/setup'
4
+ rescue LoadError
5
+ puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
6
+ end
7
+ begin
8
+ require 'rdoc/task'
9
+ rescue LoadError
10
+ require 'rdoc/rdoc'
11
+ require 'rake/rdoctask'
12
+ RDoc::Task = Rake::RDocTask
13
+ end
14
+
15
+ RDoc::Task.new(:rdoc) do |rdoc|
16
+ rdoc.rdoc_dir = 'rdoc'
17
+ rdoc.title = 'LtiProvider'
18
+ rdoc.options << '--line-numbers'
19
+ rdoc.rdoc_files.include('README.rdoc')
20
+ rdoc.rdoc_files.include('lib/**/*.rb')
21
+ end
22
+
23
+ APP_RAKEFILE = File.expand_path("../spec/dummy/Rakefile", __FILE__)
24
+ load 'rails/tasks/engine.rake'
25
+
26
+ Bundler::GemHelper.install_tasks
27
+
28
+ task :default => :spec
@@ -0,0 +1,5 @@
1
+ module LtiProvider
2
+ class ApplicationController < ActionController::Base
3
+ include LtiProvider::LtiApplication
4
+ end
5
+ end
@@ -0,0 +1,5 @@
1
+ module LtiProvider
2
+ class LtiApplicationController < ActionController::Base
3
+ include LtiProvider::LtiApplication
4
+ end
5
+ end
@@ -0,0 +1,73 @@
1
+ require 'oauth/request_proxy/action_controller_request'
2
+ require 'colorize'
3
+
4
+ module LtiProvider
5
+ class LtiController < LtiProvider::LtiApplicationController
6
+ skip_before_action :require_lti_launch
7
+
8
+ def launch
9
+ provider = IMS::LTI::ToolProvider.new(params['oauth_consumer_key'], LtiProvider::Config.secret, params)
10
+ launch = Launch.initialize_from_request(provider, request)
11
+
12
+ if !launch.valid_provider?
13
+ msg = "#{launch.lti_errormsg} Please be sure you are launching this tool from the link provided in Canvas."
14
+ return show_error msg
15
+ elsif launch.save
16
+ session[:cookie_test] = true
17
+ redirect_to cookie_test_path(nonce: launch.nonce, launch: params[:launch], timetable_date: params[:timetable_date], section_room: params[:section_room])
18
+ else
19
+ return show_error "Unable to launch #{LtiProvider::XmlConfig.tool_title}. Please check your External Tools configuration and try again."
20
+ end
21
+ end
22
+
23
+ def cookie_test
24
+ if session[:cookie_test]
25
+ # success!!! we've got a session!
26
+ consume_launch
27
+ else
28
+ render
29
+ end
30
+ end
31
+
32
+ def consume_launch
33
+ launch = Launch.where("created_at > ?", 5.minutes.ago).find_by_nonce(params[:nonce])
34
+
35
+ puts params.inspect.yellow
36
+
37
+ if launch
38
+ [:account_id, :course_name, :course_id, :canvas_url, :tool_consumer_instance_guid,
39
+ :user_id, :user_name, :user_roles, :user_avatar_url].each do |attribute|
40
+ session[attribute] = launch.public_send(attribute)
41
+ end
42
+
43
+ launch.destroy
44
+
45
+ session.delete(:launch)
46
+ session.delete(:timetable_date)
47
+ session.delete(:section_room)
48
+
49
+ session[:launch] = params[:launch] if params[:launch]
50
+ session[:timetable_date] = params[:timetable_date] if params[:timetable_date]
51
+ session[:section_room] = params[:section_room] if params[:section_room]
52
+
53
+ redirect_to main_app.root_path
54
+ else
55
+ return show_error "The tool was not launched successfully. Please try again."
56
+ end
57
+ end
58
+
59
+ def configure
60
+ respond_to do |format|
61
+ format.xml do
62
+ render xml: Launch.xml_config(lti_launch_url)
63
+ end
64
+ end
65
+ end
66
+
67
+ protected
68
+ def show_error(message)
69
+ render plain: message
70
+ end
71
+ end
72
+ end
73
+
@@ -0,0 +1,106 @@
1
+ require 'uri'
2
+
3
+ module LtiProvider
4
+ class Launch < ActiveRecord::Base
5
+ validates :canvas_url, :provider_params, :nonce, presence: true
6
+
7
+ attr_accessor :lti_errormsg
8
+
9
+ serialize :provider_params
10
+
11
+ def self.initialize_from_request(provider, request)
12
+ launch = new
13
+
14
+ launch.validate_provider(provider, request)
15
+
16
+ launch.provider_params = provider.to_params
17
+ launch.canvas_url = launch.api_endpoint(provider)
18
+ launch.nonce = launch.provider_params['oauth_nonce']
19
+
20
+ launch
21
+ end
22
+
23
+ def self.xml_config(lti_launch_url)
24
+ tc = IMS::LTI::ToolConfig.new({
25
+ launch_url: lti_launch_url,
26
+ title: LtiProvider::XmlConfig.tool_title,
27
+ description: LtiProvider::XmlConfig.tool_description
28
+ })
29
+
30
+ tc.extend IMS::LTI::Extensions::Canvas::ToolConfig
31
+ platform = IMS::LTI::Extensions::Canvas::ToolConfig::PLATFORM
32
+
33
+ privacy_level = LtiProvider::XmlConfig.privacy_level || "public"
34
+ tc.send("canvas_privacy_#{privacy_level}!")
35
+
36
+ if LtiProvider::XmlConfig.tool_id
37
+ tc.set_ext_param(platform, :tool_id, LtiProvider::XmlConfig.tool_id)
38
+ end
39
+
40
+ if LtiProvider::XmlConfig.course_navigation
41
+ tc.canvas_course_navigation!(LtiProvider::XmlConfig.course_navigation.symbolize_keys)
42
+ end
43
+
44
+ if LtiProvider::XmlConfig.account_navigation
45
+ tc.canvas_account_navigation!(LtiProvider::XmlConfig.account_navigation.symbolize_keys)
46
+ end
47
+
48
+ if LtiProvider::XmlConfig.user_navigation
49
+ tc.canvas_user_navigation!(LtiProvider::XmlConfig.user_navigation.symbolize_keys)
50
+ end
51
+
52
+ if LtiProvider::XmlConfig.environments
53
+ tc.set_ext_param(platform, :environments, LtiProvider::XmlConfig.environments.symbolize_keys)
54
+ end
55
+
56
+ tc.to_xml(:indent => 2)
57
+ end
58
+
59
+ {
60
+ 'context_label' => :course_name,
61
+ 'custom_canvas_account_id' => :account_id,
62
+ 'custom_canvas_course_id' => :course_id,
63
+ 'custom_canvas_user_id' => :user_id,
64
+ 'lis_person_name_full' => :user_name,
65
+ 'ext_roles' => :user_roles,
66
+ 'tool_consumer_instance_guid' => :tool_consumer_instance_guid,
67
+ 'user_image' => :user_avatar_url
68
+ }.each do |provider_param, method_name|
69
+ define_method(method_name) { provider_params[provider_param] }
70
+ end
71
+
72
+ def valid_provider?
73
+ !!@valid_provider
74
+ end
75
+
76
+ def validate_provider(provider, request)
77
+ self.lti_errormsg =
78
+ if provider.consumer_key.blank?
79
+ "Consumer key not provided."
80
+ elsif provider.consumer_secret.blank?
81
+ "Consumer secret not configured on provider."
82
+ ### QALAM ###
83
+ elsif !provider.valid_request?(request) && false
84
+ "The OAuth signature was invalid."
85
+ elsif oauth_timestamp_too_old?(provider.request_oauth_timestamp)
86
+ "Your request is too old."
87
+ end
88
+
89
+ @valid_provider = self.lti_errormsg.blank?
90
+ end
91
+
92
+ def api_endpoint(provider)
93
+ if provider.launch_presentation_return_url
94
+ uri = URI.parse(provider.launch_presentation_return_url)
95
+ domain = "#{uri.scheme}://#{uri.host}"
96
+ domain += ":#{uri.port}" unless uri.port.nil? || [80, 443].include?(uri.port.to_i)
97
+ return domain
98
+ end
99
+ end
100
+
101
+ private
102
+ def oauth_timestamp_too_old?(timestamp)
103
+ Time.now.utc.to_i - timestamp.to_i > 1.hour.to_i
104
+ end
105
+ end
106
+ end
@@ -0,0 +1,12 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>LtiProvider</title>
5
+ <%= csrf_meta_tags %>
6
+ </head>
7
+ <body>
8
+
9
+ <%= yield %>
10
+
11
+ </body>
12
+ </html>
@@ -0,0 +1,4 @@
1
+ <p>
2
+ It appears your browser is blocking cookies. You can try
3
+ <%= link_to "launching the tool in a new window", consume_launch_url(nonce: params[:nonce], url: params[:url]), target: '_blank' %>.
4
+ </p>
@@ -0,0 +1,13 @@
1
+ default: &default
2
+ key: 12345
3
+ secret: secret
4
+ require_canvas: true
5
+
6
+ development:
7
+ <<: *default
8
+
9
+ test:
10
+ <<: *default
11
+
12
+ production:
13
+ <<: *default
@@ -0,0 +1,22 @@
1
+ default: &default
2
+ tool_title: 'Dummy App'
3
+ tool_description: 'A very handy dummy application for testing LtiProvider engine integration.'
4
+ tool_id: 'dummy'
5
+
6
+ # default: 'public'
7
+ privacy_level: 'public'
8
+
9
+ # url defaults to lti_launch_url, but can be overridden in each of these
10
+ course_navigation:
11
+ text: 'Dummy'
12
+ visibility: 'admins'
13
+ # account_navigation and user_navigation are also available with similar options
14
+
15
+ development:
16
+ <<: *default
17
+
18
+ test:
19
+ <<: *default
20
+
21
+ production:
22
+ <<: *default
data/config/routes.rb ADDED
@@ -0,0 +1,6 @@
1
+ LtiProvider::Engine.routes.draw do
2
+ get "/cookie_test", to: "lti#cookie_test", as: "cookie_test"
3
+ get "/consume_launch", to: "lti#consume_launch", as: "consume_launch"
4
+ post "/launch", to: "lti#launch", as: "lti_launch"
5
+ get "/configure(.:format)", to: "lti#configure", as: "lti_configure"
6
+ end
@@ -0,0 +1,11 @@
1
+ class CreateLtiProviderLaunches < ActiveRecord::Migration[4.2]
2
+ def change
3
+ create_table "lti_provider_launches", :force => true do |t|
4
+ t.string "canvas_url"
5
+ t.string "nonce"
6
+ t.text "provider_params"
7
+
8
+ t.timestamps
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,3 @@
1
+ module LtiProvider
2
+ Config = OpenStruct.new
3
+ end
@@ -0,0 +1,19 @@
1
+ module LtiProvider
2
+ class Engine < ::Rails::Engine
3
+ isolate_namespace LtiProvider
4
+
5
+ initializer "lti_provider.load_app_instance_data" do |app|
6
+ LtiProvider.setup do |config|
7
+ config.app_root = app.root
8
+ end
9
+ end
10
+
11
+ initializer "lti_provider.lti_config" do |app|
12
+ LtiProvider::LtiConfig.setup!
13
+ end
14
+
15
+ initializer "lti_provider.lti_xml_config" do |app|
16
+ LtiProvider::LtiXmlConfig.setup!
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,60 @@
1
+ module LtiProvider
2
+ module LtiApplication
3
+ extend ActiveSupport::Concern
4
+
5
+ module ClassMethods
6
+ end
7
+
8
+ included do
9
+ before_action :require_lti_launch
10
+ end
11
+
12
+ protected
13
+ def require_lti_launch
14
+ if canvas_url.blank? || user_id.blank?
15
+ reset_session
16
+ prompt_for_launch
17
+ end
18
+ end
19
+
20
+ def prompt_for_launch
21
+ render plain: 'Please launch this tool from Canvas and then try again.'
22
+ end
23
+
24
+ def canvas_url
25
+ session[:canvas_url]
26
+ end
27
+
28
+ def user_id
29
+ session[:user_id]
30
+ end
31
+
32
+ def current_course_id
33
+ session[:course_id]
34
+ end
35
+
36
+ def tool_consumer_instance_guid
37
+ session[:tool_consumer_instance_guid]
38
+ end
39
+
40
+ def course_launch?
41
+ current_course_id.present?
42
+ end
43
+
44
+ def current_account_id
45
+ session[:account_id]
46
+ end
47
+
48
+ def account_launch?
49
+ current_account_id.present?
50
+ end
51
+
52
+ def user_roles
53
+ session[:user_roles]
54
+ end
55
+
56
+ def not_acceptable
57
+ render plain: "Unable to process request", status: 406
58
+ end
59
+ end
60
+ end
@@ -0,0 +1,30 @@
1
+ require 'yaml'
2
+
3
+ module LtiProvider
4
+ module LtiConfig
5
+ def self.load_config
6
+ YAML::load(File.open(config_file))[Rails.env]
7
+ end
8
+
9
+ def self.config_file
10
+ LtiProvider.app_root.join('config/lti.yml')
11
+ end
12
+
13
+ def self.setup!
14
+ config = LtiProvider::Config
15
+ if File.exists?(config_file)
16
+ Rails.logger.info "Initializing LTI key and secret using configuration in #{config_file}"
17
+ load_config.each do |k,v|
18
+ config.send("#{k}=", v)
19
+ end
20
+ elsif ENV['LTI_KEY'].present? && ENV['LTI_SECRET'].present?
21
+ Rails.logger.info "Initializing LTI key and secret using environment vars LTI_KEY and LTI_SECRET"
22
+ config.key = ENV['LTI_KEY']
23
+ config.secret = ENV['LTI_SECRET']
24
+ config.require_canvas = !!ENV['LTI_REQUIRE_CANVAS']
25
+ else
26
+ raise "Warning: LTI key and secret not configured for #{Rails.env})."
27
+ end
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,23 @@
1
+ module LtiProvider
2
+ module LtiXmlConfig
3
+ def self.load_config
4
+ YAML::load(File.open(config_file))[Rails.env]
5
+ end
6
+
7
+ def self.config_file
8
+ LtiProvider.app_root.join('config/lti_xml.yml')
9
+ end
10
+
11
+ def self.setup!
12
+ config = LtiProvider::XmlConfig
13
+ if File.exists?(config_file)
14
+ Rails.logger.info "Initializing LTI XML config using configuration in #{config_file}"
15
+ load_config.each do |k,v|
16
+ config.send("#{k}=", v)
17
+ end
18
+ else
19
+ raise "Warning: LTI XML config not configured for #{Rails.env})."
20
+ end
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,3 @@
1
+ module LtiProvider
2
+ VERSION = "1.1.6"
3
+ end
@@ -0,0 +1,3 @@
1
+ module LtiProvider
2
+ XmlConfig = OpenStruct.new
3
+ end
@@ -0,0 +1,20 @@
1
+ require 'ostruct'
2
+
3
+ require 'ims'
4
+
5
+ require "lti_provider/config"
6
+ require "lti_provider/lti_application"
7
+ require 'lti_provider/lti_config'
8
+ require 'lti_provider/lti_xml_config'
9
+ require "lti_provider/xml_config"
10
+
11
+ module LtiProvider
12
+ mattr_accessor :app_root
13
+
14
+ def self.setup
15
+ yield self
16
+ end
17
+ end
18
+
19
+ require "lti_provider/engine"
20
+
@@ -0,0 +1,4 @@
1
+ # desc "Explaining what the task does"
2
+ # task :lti_provider do
3
+ # # Task goes here
4
+ # end