panda_pal 5.19.0.beta2 → 5.19.0.beta3
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/models/panda_pal/platform/canvas.rb +49 -20
- data/lib/panda_pal/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: dc0521710ced7088a0342c4af3b5fc5e0435b3578aafe0ae1223ea98024e78ee
|
|
4
|
+
data.tar.gz: 48fb53a3d5522496fc93e8f74f4ceff4c3e510c5a8c74a2a16b4b5a83a7e1294
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: eceb5025a2c539f4ca2c9d6a2757d34595cc8071a30d34b988310ee06cf5e8224d4b514b8cc73bb0f871f2c810d31070c09c4fa3b6d58d61d5f65344aef35d4e
|
|
7
|
+
data.tar.gz: 23402bf99ee96e7ecd37bda8750e5463cf12361c703d38112d464bfa8314ca666ff8bc66cfac3d59205cb3874e7d0613e076be0b55cbb4ecd36674ffda2d285c
|
|
@@ -148,28 +148,16 @@ module PandaPal
|
|
|
148
148
|
scope_tool = existing_installs[0]
|
|
149
149
|
|
|
150
150
|
# Don't need to do an update if it already exists - Settings are stored on the LTI Key instead of the installation
|
|
151
|
-
|
|
152
|
-
|
|
151
|
+
new_install = !scope_tool
|
|
152
|
+
scope_tool ||= _with_lti_registration_unlocked(ekey) do
|
|
153
|
+
bearcat_client.send(:"create_#{ctype}_external_tool", cid, {
|
|
153
154
|
client_id: ekey[:id],
|
|
154
155
|
})
|
|
156
|
+
end
|
|
155
157
|
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
deployment_id: (scope_tool[:deployment_id].presence&.to_s if dedicated_deployment),
|
|
160
|
-
)
|
|
161
|
-
elsif !scope_tool
|
|
162
|
-
scope_tool = bearcat_client.send(:"create_#{ctype}_external_tool", cid, {
|
|
163
|
-
client_id: ekey[:id],
|
|
164
|
-
})
|
|
165
|
-
|
|
166
|
-
new_client_id = "#{ekey[:id]}"
|
|
167
|
-
new_client_id += "/#{scope_tool[:deployment_id]}" if dedicated_deployment
|
|
168
|
-
|
|
169
|
-
self.key = new_client_id
|
|
170
|
-
self.secret = ekey[:api_key]
|
|
171
|
-
|
|
172
|
-
save! if changed?
|
|
158
|
+
# The default tool's key only moves with a new install; other tools always (re)register
|
|
159
|
+
if new_install || tool != PandaPal::DEFAULT_TOOL
|
|
160
|
+
_register_lti_v1p3_key(tool, ekey, deployment_id: (scope_tool[:deployment_id].presence&.to_s if dedicated_deployment))
|
|
173
161
|
end
|
|
174
162
|
|
|
175
163
|
@new_lti_installation = scope_tool
|
|
@@ -244,7 +232,8 @@ module PandaPal
|
|
|
244
232
|
|
|
245
233
|
valid_redirect_uris.uniq!
|
|
246
234
|
|
|
247
|
-
|
|
235
|
+
created = !ekey
|
|
236
|
+
if created
|
|
248
237
|
# Create New
|
|
249
238
|
ekey = bearcat_client.post("api/lti/accounts/self/developer_keys/tool_configuration", {
|
|
250
239
|
developer_key: {
|
|
@@ -270,6 +259,10 @@ module PandaPal
|
|
|
270
259
|
|
|
271
260
|
ekey = ekey[:developer_key] || ekey
|
|
272
261
|
|
|
262
|
+
# Record a new key right away, so a failed install is retried against
|
|
263
|
+
# this key instead of creating yet another one.
|
|
264
|
+
_register_lti_v1p3_key(tool, ekey) if created
|
|
265
|
+
|
|
273
266
|
if ekey[:developer_key_account_binding][:workflow_state] == "off"
|
|
274
267
|
bearcat_client.post("api/v1/accounts/self/developer_keys/#{ekey[:id]}/developer_key_account_bindings", {
|
|
275
268
|
developer_key_account_binding: {
|
|
@@ -281,6 +274,42 @@ module PandaPal
|
|
|
281
274
|
ekey
|
|
282
275
|
end
|
|
283
276
|
|
|
277
|
+
# Points this Organization (default tool) or an LtiRegistration (other
|
|
278
|
+
# tools) at a v1.3 Developer Key.
|
|
279
|
+
def _register_lti_v1p3_key(tool, ekey, deployment_id: nil)
|
|
280
|
+
client_id = ekey[:id].to_s
|
|
281
|
+
|
|
282
|
+
if tool == PandaPal::DEFAULT_TOOL
|
|
283
|
+
self.key = deployment_id ? "#{client_id}/#{deployment_id}" : client_id
|
|
284
|
+
self.secret = ekey[:api_key] if ekey[:api_key].present?
|
|
285
|
+
save! if changed?
|
|
286
|
+
else
|
|
287
|
+
lti_registrations.find_or_create_by!(tool: tool.to_s, client_id: client_id, deployment_id: deployment_id)
|
|
288
|
+
# Drop the deployment-less placeholder recorded when the key was created
|
|
289
|
+
lti_registrations.where(tool: tool.to_s, client_id: client_id, deployment_id: nil).delete_all if deployment_id
|
|
290
|
+
end
|
|
291
|
+
end
|
|
292
|
+
|
|
293
|
+
# Canvas creates LTI Registrations with lock_deploying on, which blocks
|
|
294
|
+
# installing by client_id (when lock_lti_registrations is enabled). Unlock
|
|
295
|
+
# for the duration of the block, then put the lock back as it was.
|
|
296
|
+
def _with_lti_registration_unlocked(ekey)
|
|
297
|
+
registration_id = ekey[:lti_registration_id]
|
|
298
|
+
return yield unless registration_id.present?
|
|
299
|
+
|
|
300
|
+
registration_url = "api/v1/accounts/self/lti_registrations/#{registration_id}"
|
|
301
|
+
registration = bearcat_client.get(registration_url)
|
|
302
|
+
# Inherited registrations can only be changed by their owning account
|
|
303
|
+
return yield unless registration[:lock_deploying] && !registration[:inherited]
|
|
304
|
+
|
|
305
|
+
bearcat_client.put(registration_url, { lock_deploying: false })
|
|
306
|
+
begin
|
|
307
|
+
yield
|
|
308
|
+
ensure
|
|
309
|
+
bearcat_client.put(registration_url, { lock_deploying: true })
|
|
310
|
+
end
|
|
311
|
+
end
|
|
312
|
+
|
|
284
313
|
def _find_existing_installs(context, exists: nil, &matcher)
|
|
285
314
|
ctype, cid = _parse_lti_context(context)
|
|
286
315
|
|
data/lib/panda_pal/version.rb
CHANGED