qalam_lti_provider_engine 2.0.5 → 2.0.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/app/controllers/lti_provider/lti_controller.rb +48 -11
- data/app/models/lti_provider/launch.rb +76 -0
- data/app/models/tool_lti_key.rb +4 -0
- data/app/views/layouts/lti_provider/application.html.erb +12 -10
- data/db/migrate/20210809101126_create_tool_lti_keys.rb +11 -0
- data/lib/lti_provider/lti_application.rb +15 -6
- data/lib/lti_provider/version.rb +1 -1
- metadata +5 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 07bc159f241d267bd6e42067a210324f18198742dc3e4965959b6b95065aebe7
|
4
|
+
data.tar.gz: 5f962326d293321e6d9d229c6bd7fad1c57e4155efb03e416a540afaf30cda33
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 215e7707f1858ce5cb1c3302b324ce2b9f0e513a1b7781d171b8179f1a7d1bc5378797f268dfffd4c179445a9396f7c58b51bc976f76ff2fc9a82165ac06f54d
|
7
|
+
data.tar.gz: a31aeb671814a4f142ebd99ccb2e19acb11334e5f35c7cfc384f50d80c7deca978f3a104239cf1d6de1328efac50f353498d233b16c7ef414799a43ffce3b44f
|
@@ -4,17 +4,28 @@ require 'colorize'
|
|
4
4
|
module LtiProvider
|
5
5
|
class LtiController < LtiProvider::LtiApplicationController
|
6
6
|
skip_before_action :require_lti_launch
|
7
|
+
# skip_before_action :verify_authenticity_token, only: :launch
|
7
8
|
|
8
9
|
def launch
|
9
|
-
|
10
|
+
tool_key = params['oauth_consumer_key']
|
11
|
+
tool_secret = ((ToolLtiKey.table_exists? && ToolLtiKey.find_by(key: tool_key, canvas_url: canvas_url_domain)&.secret) or (LtiProvider::Config.secret))
|
12
|
+
|
13
|
+
# puts tool_key.inspect.green
|
14
|
+
# puts LtiProvider::Config.secret.inspect.red
|
15
|
+
# puts (ToolLtiKey.table_exists? && ToolLtiKey.find_by(key: tool_key, canvas_url: canvas_url_domain)&.secret).inspect.red
|
16
|
+
# puts tool_secret.inspect.green
|
17
|
+
|
18
|
+
provider = IMS::LTI::ToolProvider.new(tool_key, tool_secret, params)
|
10
19
|
launch = Launch.initialize_from_request(provider, request)
|
11
20
|
|
21
|
+
# puts launch.inspect.red
|
22
|
+
# puts request.origin.inspect.green
|
23
|
+
# puts request.base_url.inspect.yellow
|
12
24
|
if !launch.valid_provider?
|
13
25
|
msg = "#{launch.lti_errormsg} Please be sure you are launching this tool from the link provided in Qalam."
|
14
26
|
return show_error msg
|
15
27
|
elsif launch.save
|
16
28
|
session[:cookie_test] = true
|
17
|
-
|
18
29
|
### QALAM ###
|
19
30
|
if params[:timetable_date] && params[:section_room]
|
20
31
|
redirect_to cookie_test_path(nonce: launch.nonce, timetable_date: params[:timetable_date], section_room: params[:section_room])
|
@@ -23,26 +34,34 @@ module LtiProvider
|
|
23
34
|
end
|
24
35
|
### END ###
|
25
36
|
else
|
26
|
-
|
37
|
+
# if params[:launch_tool] && params[:launch_tool] == 'digital_library'
|
38
|
+
# redirect_to main_app.root_path and return
|
39
|
+
# else
|
40
|
+
return show_error "Unable to launch #{LtiProvider::XmlConfig.tool_title}. Please check your External Tools configuration and try again."
|
41
|
+
# end
|
27
42
|
end
|
28
43
|
end
|
29
44
|
|
30
45
|
def cookie_test
|
46
|
+
@launch = Launch.where("created_at > ?", 5.minutes.ago).find_by_nonce(params[:nonce])
|
47
|
+
|
31
48
|
if session[:cookie_test]
|
32
49
|
# success!!! we've got a session!
|
33
50
|
consume_launch
|
34
51
|
else
|
35
|
-
|
52
|
+
# if @launch.launch_tool && @launch.launch_tool == 'digital_library'
|
53
|
+
# redirect_to main_app.root_path and return
|
54
|
+
# else
|
55
|
+
render and return
|
56
|
+
# end
|
36
57
|
end
|
37
58
|
end
|
38
59
|
|
39
60
|
def consume_launch
|
40
|
-
launch
|
41
|
-
|
42
|
-
if launch
|
61
|
+
if @launch
|
43
62
|
[:account_id, :course_name, :course_id, :canvas_url, :tool_consumer_instance_guid,
|
44
63
|
:user_id, :user_name, :user_roles, :user_avatar_url, :launch_tool].each do |attribute|
|
45
|
-
session[attribute] = launch.public_send(attribute)
|
64
|
+
session[attribute] = @launch.public_send(attribute)
|
46
65
|
end
|
47
66
|
|
48
67
|
### QALAM ###
|
@@ -52,11 +71,19 @@ module LtiProvider
|
|
52
71
|
end
|
53
72
|
### END ###
|
54
73
|
|
55
|
-
launch.destroy
|
74
|
+
@launch.destroy
|
56
75
|
|
57
|
-
|
76
|
+
# if @launch.launch_tool && @launch.launch_tool == 'digital_library'
|
77
|
+
# redirect_to main_app.root_path and return
|
78
|
+
# else
|
79
|
+
redirect_to main_app.root_path and return
|
80
|
+
# end
|
58
81
|
else
|
59
|
-
|
82
|
+
# if @launch.launch_tool && @launch.launch_tool == 'digital_library'
|
83
|
+
# redirect_to main_app.root_path and return
|
84
|
+
# else
|
85
|
+
return show_error "The tool was not launched successfully. Please try again."
|
86
|
+
# end
|
60
87
|
end
|
61
88
|
end
|
62
89
|
|
@@ -72,5 +99,15 @@ module LtiProvider
|
|
72
99
|
def show_error(message)
|
73
100
|
render plain: message
|
74
101
|
end
|
102
|
+
|
103
|
+
private
|
104
|
+
def canvas_url_domain
|
105
|
+
if params['launch_presentation_return_url']
|
106
|
+
uri = URI.parse(params['launch_presentation_return_url'])
|
107
|
+
domain = "#{uri.scheme}://#{uri.host}"
|
108
|
+
domain += ":#{uri.port}" unless uri.port.nil? || [80, 443].include?(uri.port.to_i)
|
109
|
+
return domain
|
110
|
+
end
|
111
|
+
end
|
75
112
|
end
|
76
113
|
end
|
@@ -55,6 +55,82 @@ module LtiProvider
|
|
55
55
|
tc.canvas_user_navigation!(LtiProvider::XmlConfig.user_navigation.symbolize_keys)
|
56
56
|
end
|
57
57
|
|
58
|
+
### QALAM ###
|
59
|
+
|
60
|
+
if LtiProvider::XmlConfig.course_home_sub_navigation
|
61
|
+
tc.canvas_course_home_sub_navigation!(LtiProvider::XmlConfig.course_home_sub_navigation.symbolize_keys)
|
62
|
+
end
|
63
|
+
|
64
|
+
if LtiProvider::XmlConfig.course_settings_sub_navigation
|
65
|
+
tc.canvas_course_settings_sub_navigation!(LtiProvider::XmlConfig.course_settings_sub_navigation.symbolize_keys)
|
66
|
+
end
|
67
|
+
|
68
|
+
if LtiProvider::XmlConfig.global_navigation
|
69
|
+
tc.canvas_global_navigation!(LtiProvider::XmlConfig.global_navigation.symbolize_keys)
|
70
|
+
end
|
71
|
+
|
72
|
+
if LtiProvider::XmlConfig.module_menu
|
73
|
+
tc.canvas_module_menu!(LtiProvider::XmlConfig.module_menu.symbolize_keys)
|
74
|
+
end
|
75
|
+
|
76
|
+
if LtiProvider::XmlConfig.module_index_menu
|
77
|
+
tc.canvas_module_index_menu!(LtiProvider::XmlConfig.module_index_menu.symbolize_keys)
|
78
|
+
end
|
79
|
+
|
80
|
+
if LtiProvider::XmlConfig.module_group_menu
|
81
|
+
tc.canvas_module_group_menu!(LtiProvider::XmlConfig.module_group_menu.symbolize_keys)
|
82
|
+
end
|
83
|
+
|
84
|
+
if LtiProvider::XmlConfig.quiz_menu
|
85
|
+
tc.canvas_quiz_menu!(LtiProvider::XmlConfig.quiz_menu.symbolize_keys)
|
86
|
+
end
|
87
|
+
|
88
|
+
if LtiProvider::XmlConfig.quiz_index_menu
|
89
|
+
tc.canvas_quiz_index_menu!(LtiProvider::XmlConfig.quiz_index_menu.symbolize_keys)
|
90
|
+
end
|
91
|
+
|
92
|
+
if LtiProvider::XmlConfig.assignment_menu
|
93
|
+
tc.canvas_assignment_menu!(LtiProvider::XmlConfig.assignment_menu.symbolize_keys)
|
94
|
+
end
|
95
|
+
|
96
|
+
if LtiProvider::XmlConfig.assignment_index_menu
|
97
|
+
tc.canvas_assignment_index_menu!(LtiProvider::XmlConfig.assignment_index_menu.symbolize_keys)
|
98
|
+
end
|
99
|
+
|
100
|
+
if LtiProvider::XmlConfig.assignment_group_menu
|
101
|
+
tc.canvas_assignment_group_menu!(LtiProvider::XmlConfig.assignment_group_menu.symbolize_keys)
|
102
|
+
end
|
103
|
+
|
104
|
+
if LtiProvider::XmlConfig.discussion_topic_menu
|
105
|
+
tc.canvas_discussion_topic_menu!(LtiProvider::XmlConfig.discussion_topic_menu.symbolize_keys)
|
106
|
+
end
|
107
|
+
|
108
|
+
if LtiProvider::XmlConfig.discussion_topic_index_menu
|
109
|
+
tc.canvas_discussion_topic_index_menu!(LtiProvider::XmlConfig.discussion_topic_index_menu.symbolize_keys)
|
110
|
+
end
|
111
|
+
|
112
|
+
if LtiProvider::XmlConfig.wiki_page_menu
|
113
|
+
tc.canvas_wiki_page_menu!(LtiProvider::XmlConfig.wiki_page_menu.symbolize_keys)
|
114
|
+
end
|
115
|
+
|
116
|
+
if LtiProvider::XmlConfig.wiki_index_menu
|
117
|
+
tc.canvas_wiki_index_menu!(LtiProvider::XmlConfig.wiki_index_menu.symbolize_keys)
|
118
|
+
end
|
119
|
+
|
120
|
+
if LtiProvider::XmlConfig.file_menu
|
121
|
+
tc.canvas_file_menu!(LtiProvider::XmlConfig.file_menu.symbolize_keys)
|
122
|
+
end
|
123
|
+
|
124
|
+
if LtiProvider::XmlConfig.file_index_menu
|
125
|
+
tc.canvas_file_index_menu!(LtiProvider::XmlConfig.file_index_menu.symbolize_keys)
|
126
|
+
end
|
127
|
+
|
128
|
+
if LtiProvider::XmlConfig.editor_button
|
129
|
+
tc.canvas_editor_button!(LtiProvider::XmlConfig.editor_button.symbolize_keys)
|
130
|
+
end
|
131
|
+
|
132
|
+
### END ###
|
133
|
+
|
58
134
|
if LtiProvider::XmlConfig.environments
|
59
135
|
tc.set_ext_param(platform, :environments, LtiProvider::XmlConfig.environments.symbolize_keys)
|
60
136
|
end
|
@@ -1,12 +1,14 @@
|
|
1
1
|
<!DOCTYPE html>
|
2
2
|
<html>
|
3
|
-
<head>
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
<
|
8
|
-
|
9
|
-
<%=
|
10
|
-
|
11
|
-
|
12
|
-
|
3
|
+
<head>
|
4
|
+
<title>QalamLtiProvider</title>
|
5
|
+
<%= csrf_meta_tags %>
|
6
|
+
<meta name="description" content="About QalamLtiProvider">
|
7
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
8
|
+
<%= csrf_meta_tags %>
|
9
|
+
<%= csp_meta_tag %>
|
10
|
+
</head>
|
11
|
+
<body>
|
12
|
+
<%= yield %>
|
13
|
+
</body>
|
14
|
+
</html>
|
@@ -12,8 +12,13 @@ module LtiProvider
|
|
12
12
|
protected
|
13
13
|
def require_lti_launch
|
14
14
|
if canvas_url.blank? || user_id.blank?
|
15
|
-
|
16
|
-
|
15
|
+
if session[:qalam_url]
|
16
|
+
reset_session
|
17
|
+
prompt_for_launch_authorized
|
18
|
+
else
|
19
|
+
reset_session
|
20
|
+
prompt_for_launch
|
21
|
+
end
|
17
22
|
end
|
18
23
|
end
|
19
24
|
|
@@ -21,6 +26,10 @@ module LtiProvider
|
|
21
26
|
render plain: 'Please launch this tool from Qalam and then try again.'
|
22
27
|
end
|
23
28
|
|
29
|
+
def prompt_for_launch_authorized
|
30
|
+
render plain: 'You need to be login on Qalam.'
|
31
|
+
end
|
32
|
+
|
24
33
|
def canvas_url
|
25
34
|
session[:canvas_url]
|
26
35
|
end
|
@@ -59,19 +68,19 @@ module LtiProvider
|
|
59
68
|
end
|
60
69
|
|
61
70
|
def student_launch?
|
62
|
-
user_roles
|
71
|
+
user_roles&.split(',')&.include? 'urn:lti:role:ims/lis/Learner'
|
63
72
|
end
|
64
73
|
|
65
74
|
def teacher_launch?
|
66
|
-
user_roles
|
75
|
+
user_roles&.split(',')&.include? 'urn:lti:role:ims/lis/Instructor'
|
67
76
|
end
|
68
77
|
|
69
78
|
def account_admin_launch?
|
70
|
-
user_roles
|
79
|
+
user_roles&.split(',')&.include? 'urn:lti:instrole:ims/lis/Administrator'
|
71
80
|
end
|
72
81
|
|
73
82
|
def root_admin_launch?
|
74
|
-
user_roles
|
83
|
+
user_roles&.split(',')&.include? 'urn:lti:sysrole:ims/lis/SysAdmin'
|
75
84
|
end
|
76
85
|
### END ###
|
77
86
|
|
data/lib/lti_provider/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: qalam_lti_provider_engine
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.
|
4
|
+
version: 2.0.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dave Donahue
|
@@ -11,7 +11,7 @@ authors:
|
|
11
11
|
autorequire:
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
|
-
date: 2021-08-
|
14
|
+
date: 2021-08-29 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: rails
|
@@ -245,12 +245,14 @@ files:
|
|
245
245
|
- app/controllers/lti_provider/lti_application_controller.rb
|
246
246
|
- app/controllers/lti_provider/lti_controller.rb
|
247
247
|
- app/models/lti_provider/launch.rb
|
248
|
+
- app/models/tool_lti_key.rb
|
248
249
|
- app/views/layouts/lti_provider/application.html.erb
|
249
250
|
- app/views/lti_provider/lti/cookie_test.html.erb
|
250
251
|
- config/lti.yml.example
|
251
252
|
- config/lti_xml.yml.example
|
252
253
|
- config/routes.rb
|
253
254
|
- db/migrate/20130319050003_create_lti_provider_launches.rb
|
255
|
+
- db/migrate/20210809101126_create_tool_lti_keys.rb
|
254
256
|
- lib/lti_provider.rb
|
255
257
|
- lib/lti_provider/config.rb
|
256
258
|
- lib/lti_provider/engine.rb
|
@@ -312,7 +314,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
312
314
|
- !ruby/object:Gem::Version
|
313
315
|
version: '0'
|
314
316
|
requirements: []
|
315
|
-
rubygems_version: 3.2.
|
317
|
+
rubygems_version: 3.2.22
|
316
318
|
signing_key:
|
317
319
|
specification_version: 4
|
318
320
|
summary: LtiProvider is a mountable engine for handling the LTI launch and exposing
|