qalam_oauth_engine 3.0.5 → 3.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/canvas_oauth/canvas_controller.rb +1 -8
- data/app/models/canvas_oauth/authorization.rb +20 -2
- data/db/migrate/20121121005358_create_canvas_oauth_authorizations.rb +1 -0
- data/lib/canvas_oauth/canvas_api.rb +109 -59
- data/lib/canvas_oauth/canvas_api_extensions.rb +17 -7
- data/lib/canvas_oauth/canvas_application.rb +9 -1
- data/lib/canvas_oauth/canvas_config.rb +2 -2
- data/lib/canvas_oauth/version.rb +1 -1
- metadata +16 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c39bb4366b4792b9a2b0746a9073f28d410f181d82147c266939ae96489d5d5f
|
4
|
+
data.tar.gz: 97dd0420a00015b587b5a2ece17cad01fbfe0a78d95a1e8941980d4b8d076a4d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4346ca322ffd60dbb3e78e0106832255d8950e0850f1297669737c3a3ac9867e2bd95c15f4c88543dcf39625df63971341fe2524d40ddc5378d807e7551a491d
|
7
|
+
data.tar.gz: 4b7e0be12099a9312f1e125de7e6eae8d676bde404929979bbb7cc4e274cfb008d8e7e3d3d893cf5d668b75af1d7c6ffed170269343efcc2b7691fabffff8c67
|
@@ -7,7 +7,7 @@ module CanvasOauth
|
|
7
7
|
if token = canvas.get_access_token(params[:code])
|
8
8
|
set_root_account
|
9
9
|
refresh_token = canvas.refresh_token
|
10
|
-
if CanvasOauth::Authorization.cache_token(token, refresh_token, user_id, @root_account_id, tool_consumer_instance_guid)
|
10
|
+
if CanvasOauth::Authorization.cache_token(token, refresh_token, user_id, @root_account_id, tool_consumer_instance_guid, canvas_url)
|
11
11
|
redirect_to main_app.root_path
|
12
12
|
else
|
13
13
|
render plain: "Error: unable to save token"
|
@@ -23,13 +23,6 @@ module CanvasOauth
|
|
23
23
|
def verify_oauth2_state(callback_state)
|
24
24
|
callback_state.present? && callback_state == session.delete(:oauth2_state)
|
25
25
|
end
|
26
|
-
end
|
27
26
|
|
28
|
-
def set_root_account
|
29
|
-
if current_account_id
|
30
|
-
@root_account_id = canvas.root_account_id(current_account_id)
|
31
|
-
elsif current_course_id
|
32
|
-
@root_account_id = canvas.course_root_account_id(current_course_id)
|
33
|
-
end
|
34
27
|
end
|
35
28
|
end
|
@@ -2,17 +2,35 @@ module CanvasOauth
|
|
2
2
|
class Authorization < ActiveRecord::Base
|
3
3
|
validates :canvas_user_id, :token, :refresh_token, :last_used_at, presence: true
|
4
4
|
|
5
|
-
def self.cache_token(token, refresh_token, user_id, account_id, tool_consumer_instance_guid)
|
5
|
+
def self.cache_token(token, refresh_token, user_id, account_id, tool_consumer_instance_guid, canvas_url)
|
6
6
|
create do |t|
|
7
7
|
t.token = token
|
8
8
|
t.refresh_token = refresh_token
|
9
9
|
t.canvas_user_id = user_id
|
10
|
-
t.canvas_root_account_id = account_id
|
10
|
+
t.canvas_root_account_id = account_id if CanvasOauth::Authorization.column_names.include?('canvas_root_account_id')
|
11
|
+
t.canvas_url = canvas_url if canvas_url && CanvasOauth::Authorization.column_names.include?('canvas_url')
|
11
12
|
t.tool_consumer_instance_guid = tool_consumer_instance_guid
|
12
13
|
t.last_used_at = Time.now
|
13
14
|
end
|
14
15
|
end
|
15
16
|
|
17
|
+
def self.fetch_canvas_auth(user_id, tool_consumer_instance_guid, canvas_url)
|
18
|
+
user_canvas_auths = where(canvas_user_id: user_id, tool_consumer_instance_guid: tool_consumer_instance_guid).order("created_at DESC")
|
19
|
+
user_canvas_auths = user_canvas_auths.where('lower(canvas_url) LIKE :q', q: "%#{canvas_url.downcase}%") if canvas_url && CanvasOauth::Authorization.column_names.include?('canvas_url')
|
20
|
+
if canvas_auth = user_canvas_auths.first
|
21
|
+
canvas_auth.update_attribute(:last_used_at, Time.now)
|
22
|
+
return canvas_auth
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
def self.fetch_id(user_id, tool_consumer_instance_guid)
|
27
|
+
user_accounts = where(canvas_user_id: user_id, tool_consumer_instance_guid: tool_consumer_instance_guid).order("created_at DESC")
|
28
|
+
if canvas_auth = user_accounts.first
|
29
|
+
canvas_auth.update_attribute(:last_used_at, Time.now)
|
30
|
+
return canvas_auth.id
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
16
34
|
def self.fetch_account(user_id, tool_consumer_instance_guid)
|
17
35
|
user_accounts = where(canvas_user_id: user_id, tool_consumer_instance_guid: tool_consumer_instance_guid).order("created_at DESC")
|
18
36
|
if canvas_auth = user_accounts.first
|
@@ -6,6 +6,7 @@ class CreateCanvasOauthAuthorizations < ActiveRecord::Migration[4.2]
|
|
6
6
|
t.string "tool_consumer_instance_guid", :null => false
|
7
7
|
t.string "token"
|
8
8
|
t.string "refresh_token"
|
9
|
+
t.string "canvas_url"
|
9
10
|
t.datetime "last_used_at"
|
10
11
|
t.datetime "created_at", :null => false
|
11
12
|
t.datetime "updated_at", :null => false
|
@@ -4,13 +4,14 @@ module CanvasOauth
|
|
4
4
|
PER_PAGE = 50
|
5
5
|
|
6
6
|
attr_accessor :token, :refresh_token, :key, :secret
|
7
|
-
attr_reader :canvas_url, :canvas_user_id
|
7
|
+
attr_reader :id, :canvas_url, :canvas_user_id, :canvas_root_account_id
|
8
8
|
|
9
|
-
def initialize(canvas_url, canvas_user_id, canvas_root_account_id, token, refresh_token, key, secret)
|
9
|
+
def initialize(id, canvas_url, canvas_user_id, canvas_root_account_id, token, refresh_token, key, secret)
|
10
10
|
unless [key, secret].all?(&:present?)
|
11
11
|
raise "Invalid Qalam oAuth configuration"
|
12
12
|
end
|
13
|
-
|
13
|
+
|
14
|
+
self.id = id
|
14
15
|
self.refresh_token = refresh_token
|
15
16
|
self.canvas_url = canvas_url
|
16
17
|
self.canvas_user_id = canvas_user_id
|
@@ -104,18 +105,23 @@ module CanvasOauth
|
|
104
105
|
authenticated_request(:put, *params)
|
105
106
|
end
|
106
107
|
|
107
|
-
def paginated_get(url, params
|
108
|
+
def paginated_get(url, params={})
|
108
109
|
params[:query] ||= {}
|
109
|
-
params[:query][:per_page]
|
110
|
-
|
110
|
+
params[:query][:per_page] ||= PER_PAGE
|
111
|
+
params[:query][:page] ||= 1
|
111
112
|
all_pages = []
|
112
113
|
|
113
|
-
|
114
|
+
if params[:current_page]
|
115
|
+
current_page = authenticated_get(url, params)
|
114
116
|
all_pages.concat(current_page) if valid_page?(current_page)
|
117
|
+
else
|
118
|
+
while url && current_page = authenticated_get(url, params) do
|
119
|
+
all_pages.concat(current_page) if valid_page?(current_page)
|
115
120
|
|
116
|
-
|
117
|
-
|
118
|
-
|
121
|
+
links = LinkHeader.parse(current_page.headers['link'])
|
122
|
+
url = links.find_link(["rel", "next"]).try(:href)
|
123
|
+
params[:query] = nil if params[:query]
|
124
|
+
end
|
119
125
|
end
|
120
126
|
|
121
127
|
all_pages
|
@@ -135,6 +141,10 @@ module CanvasOauth
|
|
135
141
|
def canvas_root_account_id=(value)
|
136
142
|
@canvas_root_account_id = value
|
137
143
|
end
|
144
|
+
|
145
|
+
def id=(value)
|
146
|
+
@id = value
|
147
|
+
end
|
138
148
|
|
139
149
|
def hex_sis_id(name, value)
|
140
150
|
hex = value.unpack("H*")[0]
|
@@ -195,7 +205,7 @@ module CanvasOauth
|
|
195
205
|
# root_account_id
|
196
206
|
# course_root_account_id
|
197
207
|
|
198
|
-
def get_report(account_id, report_type, params)
|
208
|
+
def get_report(account_id, report_type, params={})
|
199
209
|
report = authenticated_post("/api/v1/accounts/#{account_id}/reports/#{report_type}", { body: params })
|
200
210
|
report = authenticated_get "/api/v1/accounts/#{account_id}/reports/#{report_type}/#{report['id']}"
|
201
211
|
while (report['status'] == 'created' || report['status'] == 'running')
|
@@ -212,108 +222,108 @@ module CanvasOauth
|
|
212
222
|
end
|
213
223
|
end
|
214
224
|
|
215
|
-
def get_file(file_id)
|
225
|
+
def get_file(file_id, params={})
|
216
226
|
authenticated_get "/api/v1/files/#{file_id}"
|
217
227
|
end
|
218
228
|
|
219
|
-
def get_accounts_provisioning_report(account_id)
|
229
|
+
def get_accounts_provisioning_report(account_id, params={})
|
220
230
|
get_report(account_id, :provisioning_csv, 'parameters[accounts]' => true)
|
221
231
|
end
|
222
232
|
|
223
|
-
def get_courses
|
233
|
+
def get_courses(params={})
|
224
234
|
paginated_get "/api/v1/courses"
|
225
235
|
end
|
226
236
|
|
227
|
-
def get_account(account_id)
|
237
|
+
def get_account(account_id, params={})
|
228
238
|
authenticated_get "/api/v1/accounts/#{account_id}"
|
229
239
|
end
|
230
240
|
|
231
|
-
def get_account_sub_accounts(account_id)
|
241
|
+
def get_account_sub_accounts(account_id, params={})
|
232
242
|
paginated_get "/api/v1/accounts/#{account_id}/sub_accounts", { query: { :recursive => true } }
|
233
243
|
end
|
234
244
|
|
235
|
-
def get_account_courses(account_id)
|
245
|
+
def get_account_courses(account_id, params={})
|
236
246
|
paginated_get "/api/v1/accounts/#{account_id}/courses"
|
237
247
|
end
|
238
248
|
|
239
|
-
def get_account_users(account_id)
|
249
|
+
def get_account_users(account_id, params={})
|
240
250
|
paginated_get "/api/v1/accounts/#{account_id}/users"
|
241
251
|
end
|
242
252
|
|
243
|
-
def get_course(course_id)
|
253
|
+
def get_course(course_id, params={})
|
244
254
|
authenticated_get "/api/v1/courses/#{course_id}"
|
245
255
|
end
|
246
256
|
|
247
|
-
def get_section_enrollments(section_id)
|
257
|
+
def get_section_enrollments(section_id, params={})
|
248
258
|
paginated_get "/api/v1/sections/#{section_id}/enrollments"
|
249
259
|
end
|
250
260
|
|
251
|
-
def get_user_enrollments(user_id)
|
261
|
+
def get_user_enrollments(user_id, params={})
|
252
262
|
paginated_get "/api/v1/users/#{user_id}/enrollments"
|
253
263
|
end
|
254
264
|
|
255
|
-
def get_course_users(course_id)
|
265
|
+
def get_course_users(course_id, params={})
|
256
266
|
paginated_get "/api/v1/courses/#{course_id}/users"
|
257
267
|
end
|
258
268
|
|
259
|
-
def get_all_course_users(course_id)
|
269
|
+
def get_all_course_users(course_id, params={})
|
260
270
|
paginated_get "/api/v1/courses/#{course_id}/users", { query: {enrollment_state: ["active","invited","rejected","completed","inactive"] } }
|
261
271
|
end
|
262
272
|
|
263
|
-
def get_course_teachers_and_tas(course_id)
|
273
|
+
def get_course_teachers_and_tas(course_id, params={})
|
264
274
|
paginated_get "/api/v1/courses/#{course_id}/users", { query: { enrollment_type: ['teacher', 'ta'] } }
|
265
275
|
end
|
266
276
|
|
267
|
-
def get_course_students(course_id)
|
277
|
+
def get_course_students(course_id, params={})
|
268
278
|
paginated_get "/api/v1/courses/#{course_id}/students"
|
269
279
|
end
|
270
280
|
|
271
|
-
def get_course_active_students(course_id)
|
281
|
+
def get_course_active_students(course_id, params={})
|
272
282
|
paginated_get "/api/v1/courses/#{course_id}/active_users"
|
273
283
|
end
|
274
284
|
|
275
|
-
def get_section(section_id)
|
285
|
+
def get_section(section_id, params={})
|
276
286
|
authenticated_get "/api/v1/sections/#{section_id}"
|
277
287
|
end
|
278
288
|
|
279
|
-
def get_sections(course_id)
|
289
|
+
def get_sections(course_id, params={})
|
280
290
|
paginated_get "/api/v1/courses/#{course_id}/sections", { query: { :include => ['students', 'avatar_url', 'enrollments'] } }
|
281
291
|
end
|
282
292
|
|
283
|
-
def get_assignments(course_id)
|
293
|
+
def get_assignments(course_id, params={})
|
284
294
|
paginated_get "/api/v1/courses/#{course_id}/assignments"
|
285
295
|
end
|
286
296
|
|
287
|
-
def get_assignment(course_id, assignment_id)
|
297
|
+
def get_assignment(course_id, assignment_id, params={})
|
288
298
|
authenticated_get "/api/v1/courses/#{course_id}/assignments/#{assignment_id}"
|
289
299
|
end
|
290
300
|
|
291
|
-
def get_user_profile(user_id)
|
301
|
+
def get_user_profile(user_id, params={})
|
292
302
|
authenticated_get "/api/v1/users/#{user_id}/profile"
|
293
303
|
end
|
294
304
|
|
295
|
-
def create_assignment(course_id, params)
|
305
|
+
def create_assignment(course_id, params={})
|
296
306
|
authenticated_post "/api/v1/courses/#{course_id}/assignments", { body: { assignment: params } }
|
297
307
|
end
|
298
308
|
|
299
|
-
def update_assignment(course_id, assignment_id, params)
|
309
|
+
def update_assignment(course_id, assignment_id, params={})
|
300
310
|
authenticated_put "/api/v1/courses/#{course_id}/assignments/#{assignment_id}", { body: { assignment: params } }
|
301
311
|
end
|
302
312
|
|
303
|
-
def grade_assignment(course_id, assignment_id, user_id, params)
|
313
|
+
def grade_assignment(course_id, assignment_id, user_id, params={})
|
304
314
|
authenticated_put "/api/v1/courses/#{course_id}/assignments/#{assignment_id}/submissions/#{user_id}", { body: params }
|
305
315
|
end
|
306
316
|
|
307
|
-
def get_submission(course_id, assignment_id, user_id)
|
317
|
+
def get_submission(course_id, assignment_id, user_id, params={})
|
308
318
|
authenticated_get "/api/v1/courses/#{course_id}/assignments/#{assignment_id}/submissions/#{user_id}"
|
309
319
|
end
|
310
320
|
|
311
|
-
def course_account_id(course_id)
|
321
|
+
def course_account_id(course_id, params={})
|
312
322
|
course = get_course(course_id)
|
313
323
|
course['account_id'] if course
|
314
324
|
end
|
315
325
|
|
316
|
-
def root_account_id(account_id)
|
326
|
+
def root_account_id(account_id, params={})
|
317
327
|
if account_id && account = get_account(account_id)
|
318
328
|
root_id = account['root_account_id']
|
319
329
|
end
|
@@ -321,7 +331,7 @@ module CanvasOauth
|
|
321
331
|
root_id || account_id
|
322
332
|
end
|
323
333
|
|
324
|
-
def course_root_account_id(course_id)
|
334
|
+
def course_root_account_id(course_id, params={})
|
325
335
|
root_account_id(course_account_id(course_id))
|
326
336
|
end
|
327
337
|
### END CANVAS API ###
|
@@ -329,44 +339,84 @@ module CanvasOauth
|
|
329
339
|
### QALAM API ENDPOINTS ###
|
330
340
|
# get_canvas_user_profile
|
331
341
|
# get_course_active_pages
|
332
|
-
#
|
333
|
-
# account_external_tool_update
|
342
|
+
# update_external_tool_nav
|
334
343
|
# get_school_details
|
335
|
-
#
|
336
|
-
#
|
337
|
-
|
338
|
-
|
344
|
+
# get_school_grades
|
345
|
+
# get_school_grade
|
346
|
+
# get_school_class_rooms
|
347
|
+
# get_school_class_room
|
348
|
+
# get_school_subjects
|
349
|
+
# get_school_subject
|
350
|
+
# get_students_by_grade
|
351
|
+
# get_students_by_class_room
|
352
|
+
|
353
|
+
def get_canvas_user_profile(params={})
|
339
354
|
authenticated_get "/api/v1/users/#{canvas_user_id}/profile"
|
340
355
|
end
|
341
356
|
|
342
|
-
def get_course_active_pages(course_id, publish=nil)
|
357
|
+
def get_course_active_pages(course_id, publish=nil, params={})
|
343
358
|
unless publish.nil?
|
344
|
-
paginated_get "/api/v1/courses/#{course_id}/pages?published=#{publish}&sort=created_at&order=desc"
|
359
|
+
paginated_get "/api/v1/courses/#{course_id}/pages?published=#{publish}&sort=created_at&order=desc", params
|
345
360
|
else
|
346
|
-
paginated_get "/api/v1/courses/#{course_id}/pages?sort=created_at&order=desc"
|
361
|
+
paginated_get "/api/v1/courses/#{course_id}/pages?sort=created_at&order=desc", params
|
347
362
|
end
|
348
363
|
end
|
349
364
|
|
350
|
-
def
|
351
|
-
|
352
|
-
|
365
|
+
def update_external_tool_nav(external_tool_url, tool_id, publish, type, account_id=@canvas_root_account_id, params={})
|
366
|
+
account_id ||= @canvas_root_account_id
|
367
|
+
if type == 'account'
|
368
|
+
body = {"account_navigation"=>{"enabled"=>"#{publish}"},
|
369
|
+
"tool_id"=>tool_id, "external_tool_url"=>external_tool_url}
|
370
|
+
elsif type == 'course'
|
371
|
+
body = {"course_navigation"=>{"enabled"=>"#{publish}"},
|
372
|
+
"tool_id"=>tool_id, "external_tool_url"=>external_tool_url}
|
373
|
+
end
|
374
|
+
authenticated_put "/api/v1/accounts/#{account_id}/external_tools_url", { body: body } if body
|
353
375
|
end
|
354
376
|
|
355
|
-
def
|
356
|
-
|
357
|
-
|
377
|
+
def get_school_details(account_id=@canvas_root_account_id, params={})
|
378
|
+
account_id ||= @canvas_root_account_id
|
379
|
+
authenticated_get "/api/v1/accounts/#{account_id}/school_details"
|
358
380
|
end
|
359
381
|
|
360
|
-
def
|
361
|
-
|
382
|
+
def get_school_grades(account_id=@canvas_root_account_id, params={})
|
383
|
+
account_id ||= @canvas_root_account_id
|
384
|
+
paginated_get "/api/v1/accounts/#{account_id}/school_grades", params
|
385
|
+
end
|
386
|
+
|
387
|
+
def get_school_grade(grade_id, account_id=@canvas_root_account_id, params={})
|
388
|
+
account_id ||= @canvas_root_account_id
|
389
|
+
authenticated_get "/api/v1/accounts/#{account_id}/school_grades/#{grade_id}", params
|
390
|
+
end
|
391
|
+
|
392
|
+
def get_school_subjects(account_id=@canvas_root_account_id, params={})
|
393
|
+
account_id ||= @canvas_root_account_id
|
394
|
+
paginated_get "/api/v1/accounts/#{account_id}/school_subjects", params
|
395
|
+
end
|
396
|
+
|
397
|
+
def get_school_subject(subject_id, account_id=@canvas_root_account_id, params={})
|
398
|
+
account_id ||= @canvas_root_account_id
|
399
|
+
authenticated_get "/api/v1/accounts/#{account_id}/school_subjects/#{subject_id}", params
|
400
|
+
end
|
401
|
+
|
402
|
+
def get_school_class_rooms(account_id=@canvas_root_account_id, params={})
|
403
|
+
account_id ||= @canvas_root_account_id
|
404
|
+
paginated_get "/api/v1/accounts/#{account_id}/school_class_rooms", params
|
405
|
+
end
|
406
|
+
|
407
|
+
def get_school_class_room(class_room_id, account_id=@canvas_root_account_id, params={})
|
408
|
+
account_id ||= @canvas_root_account_id
|
409
|
+
authenticated_get "/api/v1/accounts/#{account_id}/school_class_rooms/#{class_room_id}", params
|
362
410
|
end
|
363
411
|
|
364
|
-
def
|
365
|
-
|
412
|
+
def get_students_by_grade(grade_id, account_id=@canvas_root_account_id, params={})
|
413
|
+
account_id ||= @canvas_root_account_id
|
414
|
+
paginated_get "/api/v1/accounts/#{account_id}/grade_students/#{grade_id}", params
|
366
415
|
end
|
367
416
|
|
368
|
-
def
|
369
|
-
|
417
|
+
def get_students_by_class_room(class_room_id, account_id=@canvas_root_account_id, params={})
|
418
|
+
account_id ||= @canvas_root_account_id
|
419
|
+
paginated_get "/api/v1/accounts/#{account_id}/class_room_students/#{class_room_id}", params
|
370
420
|
end
|
371
421
|
### END QALAM API ###
|
372
422
|
end
|
@@ -1,12 +1,22 @@
|
|
1
1
|
module CanvasOauth
|
2
2
|
class CanvasApiExtensions
|
3
|
-
def self.build(
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
3
|
+
def self.build(user_id, tool_consumer_instance_guid, canvas_url)
|
4
|
+
canvas_auth = CanvasOauth::Authorization.fetch_canvas_auth(user_id, tool_consumer_instance_guid, canvas_url)
|
5
|
+
|
6
|
+
id = canvas_auth&.id
|
7
|
+
account_id = canvas_auth&.canvas_root_account_id
|
8
|
+
token = canvas_auth&.token
|
9
|
+
refresh_token = canvas_auth&.refresh_token
|
10
|
+
|
11
|
+
if canvas_url && CanvasLtiKey.table_exists?
|
12
|
+
canvas_lti_key = CanvasLtiKey.where('lower(canvas_url) LIKE :q', q: "%#{canvas_url.downcase}%").first
|
13
|
+
canvas_key = canvas_lti_key&.key or CanvasConfig.key
|
14
|
+
canvas_secret = canvas_lti_key&.secret or CanvasConfig.secret
|
15
|
+
else
|
16
|
+
canvas_key = CanvasConfig.key
|
17
|
+
canvas_secret = CanvasConfig.secret
|
18
|
+
end
|
19
|
+
CanvasApi.new(id, canvas_url, user_id, account_id, token, refresh_token, canvas_key, canvas_secret)
|
10
20
|
end
|
11
21
|
end
|
12
22
|
end
|
@@ -16,7 +16,7 @@ module CanvasOauth
|
|
16
16
|
|
17
17
|
protected
|
18
18
|
def initialize_canvas
|
19
|
-
@canvas = ::CanvasOauth::CanvasApiExtensions.build(
|
19
|
+
@canvas = ::CanvasOauth::CanvasApiExtensions.build(user_id, tool_consumer_instance_guid, canvas_url)
|
20
20
|
end
|
21
21
|
|
22
22
|
def canvas
|
@@ -58,6 +58,14 @@ module CanvasOauth
|
|
58
58
|
# be overridden or the session data needs to be set up by the time the
|
59
59
|
# oauth filter runs (like with the lti_provider_engine)
|
60
60
|
|
61
|
+
def set_root_account
|
62
|
+
if session[:account_id]
|
63
|
+
@root_account_id = canvas.root_account_id(session[:account_id])
|
64
|
+
elsif session[:course_id]
|
65
|
+
@root_account_id = canvas.course_root_account_id(session[:course_id])
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
61
69
|
def canvas_url
|
62
70
|
session[:canvas_url]
|
63
71
|
end
|
@@ -13,12 +13,12 @@ module CanvasOauth
|
|
13
13
|
|
14
14
|
def self.setup!
|
15
15
|
if File.exists?(config_file)
|
16
|
-
Rails.logger.info "Initializing Qalam using configuration in #{config_file}"
|
16
|
+
Rails.logger.info "Initializing Qalam using configuration in #{config_file}".green
|
17
17
|
config = load_config
|
18
18
|
self.key = config['key']
|
19
19
|
self.secret = config['secret']
|
20
20
|
elsif ENV['CANVAS_KEY'].present? && ENV['CANVAS_SECRET'].present?
|
21
|
-
Rails.logger.info "Initializing Qalam using environment vars CANVAS_KEY and CANVAS_SECRET"
|
21
|
+
Rails.logger.info "Initializing Qalam using environment vars CANVAS_KEY and CANVAS_SECRET".green
|
22
22
|
self.key = ENV['CANVAS_KEY']
|
23
23
|
self.secret = ENV['CANVAS_SECRET']
|
24
24
|
else
|
data/lib/canvas_oauth/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: qalam_oauth_engine
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.0.
|
4
|
+
version: 3.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-30 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: httparty
|
@@ -61,6 +61,20 @@ dependencies:
|
|
61
61
|
- - "<"
|
62
62
|
- !ruby/object:Gem::Version
|
63
63
|
version: '6.1'
|
64
|
+
- !ruby/object:Gem::Dependency
|
65
|
+
name: colorize
|
66
|
+
requirement: !ruby/object:Gem::Requirement
|
67
|
+
requirements:
|
68
|
+
- - ">="
|
69
|
+
- !ruby/object:Gem::Version
|
70
|
+
version: '0'
|
71
|
+
type: :runtime
|
72
|
+
prerelease: false
|
73
|
+
version_requirements: !ruby/object:Gem::Requirement
|
74
|
+
requirements:
|
75
|
+
- - ">="
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '0'
|
64
78
|
- !ruby/object:Gem::Dependency
|
65
79
|
name: byebug
|
66
80
|
requirement: !ruby/object:Gem::Requirement
|