qalam_lti_provider_engine 2.0.7 → 2.0.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/controllers/lti_provider/lti_controller.rb +39 -22
- 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 +5 -5
- data/lib/lti_provider/version.rb +1 -1
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 58133aa1d62a24703c017cde3034ec79c66fdcfd933b199fd50b5b48eab54911
|
4
|
+
data.tar.gz: 99b8895d05651991ed895948c7a722be8e3825320114f7ca0f7741a1a7826e6a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '070911c42da9f77387c0f70ecb192390dab703191a3becf5631410e8535b42c8e98c63d84b80a635d715ff1a5bca1bbb0e378337d351a41a4e33b17bbea77abf'
|
7
|
+
data.tar.gz: 32257903add2518d9ba4f9f1e2a245a0764f3c75e5fb6066c2b09861b5721b1ae43a650a4f87f4fe7bbbbfc6c5bebbb11f0a3fdd1321f0d1b28e87b957087936
|
@@ -4,21 +4,28 @@ require 'colorize'
|
|
4
4
|
module LtiProvider
|
5
5
|
class LtiController < LtiProvider::LtiApplicationController
|
6
6
|
skip_before_action :require_lti_launch
|
7
|
-
|
7
|
+
skip_before_action :verify_authenticity_token, only: :launch
|
8
8
|
|
9
9
|
def launch
|
10
|
-
|
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)
|
11
19
|
launch = Launch.initialize_from_request(provider, request)
|
12
20
|
|
13
|
-
puts launch.inspect.red
|
14
|
-
puts request.origin.inspect.green
|
15
|
-
puts request.base_url.inspect.yellow
|
21
|
+
# puts launch.inspect.red
|
22
|
+
# puts request.origin.inspect.green
|
23
|
+
# puts request.base_url.inspect.yellow
|
16
24
|
if !launch.valid_provider?
|
17
25
|
msg = "#{launch.lti_errormsg} Please be sure you are launching this tool from the link provided in Qalam."
|
18
26
|
return show_error msg
|
19
27
|
elsif launch.save
|
20
28
|
session[:cookie_test] = true
|
21
|
-
|
22
29
|
### QALAM ###
|
23
30
|
if params[:timetable_date] && params[:section_room]
|
24
31
|
redirect_to cookie_test_path(nonce: launch.nonce, timetable_date: params[:timetable_date], section_room: params[:section_room])
|
@@ -27,11 +34,11 @@ module LtiProvider
|
|
27
34
|
end
|
28
35
|
### END ###
|
29
36
|
else
|
30
|
-
if params[:launch_tool] && params[:launch_tool] == 'digital_library'
|
31
|
-
|
32
|
-
else
|
37
|
+
# if params[:launch_tool] && params[:launch_tool] == 'digital_library'
|
38
|
+
# redirect_to main_app.root_path and return
|
39
|
+
# else
|
33
40
|
return show_error "Unable to launch #{LtiProvider::XmlConfig.tool_title}. Please check your External Tools configuration and try again."
|
34
|
-
end
|
41
|
+
# end
|
35
42
|
end
|
36
43
|
end
|
37
44
|
|
@@ -42,11 +49,11 @@ module LtiProvider
|
|
42
49
|
# success!!! we've got a session!
|
43
50
|
consume_launch
|
44
51
|
else
|
45
|
-
if @launch.launch_tool && @launch.launch_tool == 'digital_library'
|
46
|
-
|
47
|
-
else
|
52
|
+
# if @launch.launch_tool && @launch.launch_tool == 'digital_library'
|
53
|
+
# redirect_to main_app.root_path and return
|
54
|
+
# else
|
48
55
|
render and return
|
49
|
-
end
|
56
|
+
# end
|
50
57
|
end
|
51
58
|
end
|
52
59
|
|
@@ -66,17 +73,17 @@ module LtiProvider
|
|
66
73
|
|
67
74
|
@launch.destroy
|
68
75
|
|
69
|
-
if @launch.launch_tool && @launch.launch_tool == 'digital_library'
|
70
|
-
|
71
|
-
else
|
76
|
+
# if @launch.launch_tool && @launch.launch_tool == 'digital_library'
|
77
|
+
# redirect_to main_app.root_path and return
|
78
|
+
# else
|
72
79
|
redirect_to main_app.root_path and return
|
73
|
-
end
|
80
|
+
# end
|
74
81
|
else
|
75
|
-
if @launch.launch_tool && @launch.launch_tool == 'digital_library'
|
76
|
-
|
77
|
-
else
|
82
|
+
# if @launch.launch_tool && @launch.launch_tool == 'digital_library'
|
83
|
+
# redirect_to main_app.root_path and return
|
84
|
+
# else
|
78
85
|
return show_error "The tool was not launched successfully. Please try again."
|
79
|
-
end
|
86
|
+
# end
|
80
87
|
end
|
81
88
|
end
|
82
89
|
|
@@ -92,5 +99,15 @@ module LtiProvider
|
|
92
99
|
def show_error(message)
|
93
100
|
render plain: message
|
94
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
|
95
112
|
end
|
96
113
|
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>
|
@@ -59,19 +59,19 @@ module LtiProvider
|
|
59
59
|
end
|
60
60
|
|
61
61
|
def student_launch?
|
62
|
-
user_roles
|
62
|
+
user_roles&.split(',')&.include? 'urn:lti:role:ims/lis/Learner'
|
63
63
|
end
|
64
64
|
|
65
65
|
def teacher_launch?
|
66
|
-
user_roles
|
66
|
+
user_roles&.split(',')&.include? 'urn:lti:role:ims/lis/Instructor'
|
67
67
|
end
|
68
68
|
|
69
69
|
def account_admin_launch?
|
70
|
-
user_roles
|
70
|
+
user_roles&.split(',')&.include? 'urn:lti:instrole:ims/lis/Administrator'
|
71
71
|
end
|
72
72
|
|
73
73
|
def root_admin_launch?
|
74
|
-
user_roles
|
74
|
+
user_roles&.split(',')&.include? 'urn:lti:sysrole:ims/lis/SysAdmin'
|
75
75
|
end
|
76
76
|
### END ###
|
77
77
|
|
@@ -79,4 +79,4 @@ module LtiProvider
|
|
79
79
|
render plain: "Unable to process request", status: 406
|
80
80
|
end
|
81
81
|
end
|
82
|
-
end
|
82
|
+
end
|
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.8
|
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-09 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
|