panda_pal 5.6.9 → 5.6.11
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +2 -0
- data/app/models/panda_pal/organization.rb +12 -4
- data/app/models/panda_pal/platform/canvas.rb +73 -37
- data/app/models/panda_pal/platform.rb +5 -6
- data/lib/panda_pal/engine.rb +1 -1
- data/lib/panda_pal/version.rb +1 -1
- data/panda_pal.gemspec +1 -1
- data/spec/dummy/log/test.log +0 -18554
- metadata +43 -45
- data/spec/dummy/log/development.log +0 -162
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5c795ed3f22dd6907af02906b115d21f5a3e0b178278ac94a6a54fd3e41a838a
|
4
|
+
data.tar.gz: d9e8d0152d0c58cf8473519cd5f92b8e5946c235f72c0f2448a9c22c646c9af1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 06ac4df41b5b2cc268e06dff1a98322445474947c30b88da4770ec532ea834c62a106368e5ea77c64289bd7b6af7b0a837e1de1d6c71786f45f30ba226face9f
|
7
|
+
data.tar.gz: def73050fcecfacb79c4956188b933f81abfd5cd6791c05143df984473b3cde9e149eccc0f0b36729085d58b781160d2a5eddd5bda8b8ef384d4c5b66476fcdd
|
data/README.md
CHANGED
@@ -28,6 +28,8 @@ org.install_lti(
|
|
28
28
|
host: "https://your_lti.herokuapp.com",
|
29
29
|
context: "account/self", # (Optional) Or "account/3", "course/1", etc
|
30
30
|
exists: :error, # (Optional) Action to take if an LTI with the same Key already exists. Options are :error, :replace, :duplicate
|
31
|
+
version: "v1p3", # (Optional, default `v1p3`) LTI Version. Accepts `v1p0` or `v1p3`.
|
32
|
+
dedicated_deployment: false, # (Optional) If true, the Organization will be updated to link to a single deployment rather then to the general LTI Key. (experimental)
|
31
33
|
)
|
32
34
|
```
|
33
35
|
|
@@ -72,10 +72,6 @@ module PandaPal
|
|
72
72
|
find_by_name(Apartment::Tenant.current)
|
73
73
|
end
|
74
74
|
|
75
|
-
PandaPal.resolved_extensions_for(self).each do |ext|
|
76
|
-
include ext
|
77
|
-
end
|
78
|
-
|
79
75
|
def create_api(logic, expiration: nil, uses: nil, host: nil)
|
80
76
|
switch_tenant do
|
81
77
|
logic = "current_organization.#{logic}" if logic.is_a?(Symbol)
|
@@ -102,6 +98,14 @@ module PandaPal
|
|
102
98
|
switch_tenant if do_switch
|
103
99
|
end
|
104
100
|
|
101
|
+
def platform_extensions(platform_type)
|
102
|
+
return self unless defined?(platform_type::OrgExtension)
|
103
|
+
return self if self.class < platform_type::OrgExtension
|
104
|
+
|
105
|
+
scl = platform_type.org_subclass
|
106
|
+
scl ? becomes(scl) : self
|
107
|
+
end
|
108
|
+
|
105
109
|
if !PandaPal.lti_options[:platform].present? || PandaPal.lti_options[:platform].is_a?(String)
|
106
110
|
platform_cls = Platform.resolve_platform_class(nil) rescue nil
|
107
111
|
if platform_cls && defined?(platform_cls::OrgExtension)
|
@@ -109,6 +113,10 @@ module PandaPal
|
|
109
113
|
end
|
110
114
|
end
|
111
115
|
|
116
|
+
PandaPal.resolved_extensions_for(self).each do |ext|
|
117
|
+
include ext
|
118
|
+
end
|
119
|
+
|
112
120
|
private
|
113
121
|
|
114
122
|
def create_schema
|
@@ -28,54 +28,77 @@ module PandaPal
|
|
28
28
|
module OrgExtension
|
29
29
|
extend ActiveSupport::Concern
|
30
30
|
|
31
|
-
|
32
|
-
|
31
|
+
included do
|
32
|
+
define_model_callbacks :lti_install
|
33
|
+
end
|
33
34
|
|
35
|
+
def _parse_lti_context(context)
|
34
36
|
context = context.to_s
|
35
37
|
context = 'account/self' if context == 'root_account'
|
36
38
|
cid, ctype = context.split(/[\.\/]/).reverse
|
37
39
|
ctype ||= 'account'
|
38
40
|
|
39
|
-
|
40
|
-
|
41
|
-
lti[:consumer_key] == self.key
|
42
|
-
end
|
41
|
+
[ctype, cid]
|
42
|
+
end
|
43
43
|
|
44
|
-
|
45
|
-
|
46
|
-
description: PandaPal.lti_options[:description],
|
47
|
-
consumer_key: self.key,
|
48
|
-
shared_secret: self.secret,
|
49
|
-
privacy_level: "public",
|
50
|
-
config_type: 'by_url',
|
51
|
-
config_url: PandaPal::LaunchUrlHelpers.resolve_route(:v1p0_config_url, host: host),
|
52
|
-
}
|
44
|
+
def install_lti(host: nil, context: :root_account, version: 'v1p3', exists: :error, dedicated_deployment: false)
|
45
|
+
raise "Automatically installing this LTI requires Bearcat." unless defined?(Bearcat)
|
53
46
|
|
54
|
-
|
55
|
-
|
56
|
-
ekey = _ensure_lti_v1p3_key(exists: exists)
|
47
|
+
run_callbacks :lti_install do
|
48
|
+
ctype, cid = _parse_lti_context(context)
|
57
49
|
|
58
|
-
|
59
|
-
|
60
|
-
|
50
|
+
if version == 'v1p0'
|
51
|
+
existing_installs = _find_existing_installs(exists: exists) do |lti|
|
52
|
+
lti[:consumer_key] == self.key
|
53
|
+
end
|
61
54
|
|
62
|
-
|
63
|
-
|
64
|
-
|
55
|
+
conf = {
|
56
|
+
name: PandaPal.lti_options[:title],
|
57
|
+
description: PandaPal.lti_options[:description],
|
58
|
+
consumer_key: self.key,
|
59
|
+
shared_secret: self.secret,
|
60
|
+
privacy_level: "public",
|
61
|
+
config_type: 'by_url',
|
62
|
+
config_url: PandaPal::LaunchUrlHelpers.resolve_route(:v1p0_config_url, host: host),
|
63
|
+
}
|
64
|
+
|
65
|
+
api_result = existing_installs[0] ? bearcat_client.send(:"edit_#{ctype}_external_tool", cid, existing_installs[0][:id], conf) : bearcat_client.send(:"create_#{ctype}_external_tool", cid, conf)
|
66
|
+
|
67
|
+
@new_lti_installation = api_result
|
68
|
+
elsif version == 'v1p3'
|
69
|
+
ekey = _ensure_lti_v1p3_key(exists: exists, host: host)
|
70
|
+
|
71
|
+
existing_installs = _find_existing_installs(context, exists: exists) do |lti|
|
72
|
+
lti[:developer_key_id] == (ekey[:id] % 10_000_000_000_000)
|
73
|
+
end
|
65
74
|
|
66
|
-
|
67
|
-
new_client_id += "/#{scope_tool[:deployment_id]}" if dedicated_deployment
|
75
|
+
scope_tool = existing_installs[0]
|
68
76
|
|
69
|
-
|
70
|
-
|
77
|
+
# Don't need to do an update if it already exists - Settings are stored on the LTI Key instead of the installation
|
78
|
+
unless scope_tool
|
79
|
+
scope_tool = bearcat_client.send(:"create_#{ctype}_external_tool", cid, {
|
80
|
+
client_id: ekey[:id],
|
81
|
+
})
|
71
82
|
|
72
|
-
|
73
|
-
|
74
|
-
|
83
|
+
new_client_id = "#{ekey[:id]}"
|
84
|
+
new_client_id += "/#{scope_tool[:deployment_id]}" if dedicated_deployment
|
85
|
+
|
86
|
+
self.key = new_client_id
|
87
|
+
self.secret = ekey[:api_key]
|
88
|
+
|
89
|
+
save! if changed?
|
90
|
+
end
|
91
|
+
|
92
|
+
@new_lti_installation = scope_tool
|
93
|
+
else
|
94
|
+
raise "Unrecognized LTI Version #{version}"
|
95
|
+
end
|
75
96
|
end
|
97
|
+
|
98
|
+
save!
|
76
99
|
end
|
77
100
|
|
78
|
-
def _ensure_lti_v1p3_key(exists:)
|
101
|
+
def _ensure_lti_v1p3_key(exists:, host:)
|
79
102
|
current_client_id = self.key.split('/')[0]
|
80
103
|
|
81
104
|
existing_keys = []
|
@@ -111,7 +134,10 @@ module PandaPal
|
|
111
134
|
# Update Existing
|
112
135
|
ekey = bearcat_client.put("api/lti/developer_keys/#{ekey[:id]}/tool_configuration", {
|
113
136
|
developer_key: ekey[:developer_key],
|
114
|
-
tool_configuration: lti_json,
|
137
|
+
# tool_configuration: lti_json,
|
138
|
+
tool_configuration: {
|
139
|
+
settings: lti_json,
|
140
|
+
},
|
115
141
|
})
|
116
142
|
end
|
117
143
|
|
@@ -128,26 +154,32 @@ module PandaPal
|
|
128
154
|
ekey
|
129
155
|
end
|
130
156
|
|
131
|
-
def _find_existing_installs(exists
|
157
|
+
def _find_existing_installs(context, exists: nil, &matcher)
|
158
|
+
ctype, cid = _parse_lti_context(context)
|
159
|
+
|
132
160
|
existing_installs = bearcat_client.send(:"#{ctype}_external_tools", cid).all_pages_each.filter do |cet|
|
133
161
|
matcher.call(cet)
|
134
162
|
end
|
135
163
|
|
136
|
-
if existing_installs.present?
|
164
|
+
if exists.present? && existing_installs.present?
|
137
165
|
case exists
|
138
166
|
when :error
|
139
167
|
raise "Tool with key #{self.key} already installed"
|
140
168
|
when :duplicate
|
169
|
+
[]
|
141
170
|
when :replace
|
142
171
|
existing_installs.each do |install|
|
143
172
|
bearcat_client.send(:"delete_#{ctype}_external_tool", cid, install[:id])
|
144
173
|
end
|
174
|
+
[]
|
175
|
+
when :update
|
176
|
+
existing_installs
|
145
177
|
else
|
146
178
|
raise "exists: #{exists} is not supported"
|
147
179
|
end
|
180
|
+
else
|
181
|
+
existing_installs
|
148
182
|
end
|
149
|
-
|
150
|
-
existing_installs
|
151
183
|
end
|
152
184
|
|
153
185
|
def reinstall_lti!(*args, **kwargs)
|
@@ -199,6 +231,10 @@ module PandaPal
|
|
199
231
|
end
|
200
232
|
end
|
201
233
|
|
234
|
+
def lti_installations(context= :root_account)
|
235
|
+
_find_existing_installs(context)
|
236
|
+
end
|
237
|
+
|
202
238
|
def canvas_url
|
203
239
|
PandaPal::Platform.find_org_setting([
|
204
240
|
"canvas.base_url",
|
@@ -72,14 +72,13 @@ module PandaPal
|
|
72
72
|
raise "Unknown platform '#{platform}'"
|
73
73
|
end
|
74
74
|
|
75
|
-
def self.
|
75
|
+
def self.org_subclass
|
76
76
|
return nil unless defined?(self::OrgExtension)
|
77
|
+
oext = self::OrgExtension
|
77
78
|
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
org
|
79
|
+
@org_subclass ||= Class.new(PandaPal::Organization) do
|
80
|
+
include oext
|
81
|
+
end
|
83
82
|
end
|
84
83
|
|
85
84
|
protected
|
data/lib/panda_pal/engine.rb
CHANGED
@@ -103,7 +103,7 @@ module PandaPal
|
|
103
103
|
|
104
104
|
initializer "panda_pal.serialze_symbols" do |app|
|
105
105
|
app.config.active_record.yaml_column_permitted_classes ||= []
|
106
|
-
app.config.active_record.yaml_column_permitted_classes |= [Symbol]
|
106
|
+
app.config.active_record.yaml_column_permitted_classes |= [Symbol, ActiveSupport::Duration]
|
107
107
|
rescue
|
108
108
|
end
|
109
109
|
|
data/lib/panda_pal/version.rb
CHANGED
data/panda_pal.gemspec
CHANGED
@@ -24,7 +24,7 @@ Gem::Specification.new do |s|
|
|
24
24
|
s.add_dependency 'ros-apartment', '~> 2.2'
|
25
25
|
s.add_dependency 'ims-lti', '~> 1.2.4'
|
26
26
|
s.add_dependency 'browser', '2.5.0'
|
27
|
-
s.add_dependency 'attr_encrypted', '~>
|
27
|
+
s.add_dependency 'attr_encrypted', '~> 4.0.0'
|
28
28
|
s.add_dependency 'secure_headers', '~> 6.1'
|
29
29
|
s.add_dependency 'json-jwt'
|
30
30
|
s.add_dependency 'jwt'
|