panda_pal 5.10.0 → 5.11.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (99) hide show
  1. checksums.yaml +4 -4
  2. data/MIT-LICENSE +0 -0
  3. data/README.md +19 -21
  4. data/Rakefile +0 -0
  5. data/app/assets/config/panda_pal_manifest.js +0 -0
  6. data/app/assets/javascripts/panda_pal/application.js +0 -0
  7. data/app/assets/javascripts/panda_pal/lti.js +0 -0
  8. data/app/assets/stylesheets/panda_pal/application.css +0 -0
  9. data/app/assets/stylesheets/panda_pal/lti.css +0 -0
  10. data/app/controllers/panda_pal/api_call_controller.rb +0 -0
  11. data/app/controllers/panda_pal/application_controller.rb +0 -0
  12. data/app/controllers/panda_pal/lti_controller.rb +0 -0
  13. data/app/controllers/panda_pal/lti_v1_p0_controller.rb +0 -0
  14. data/app/controllers/panda_pal/lti_v1_p3_controller.rb +15 -1
  15. data/app/helpers/panda_pal/application_helper.rb +0 -0
  16. data/app/jobs/panda_pal/jobs/grade_passback_job.rb +0 -0
  17. data/app/lib/lti_xml/base_platform.rb +0 -0
  18. data/app/lib/lti_xml/bridge_platform.rb +0 -0
  19. data/app/lib/lti_xml/canvas_platform.rb +0 -0
  20. data/app/lib/panda_pal/launch_url_helpers.rb +0 -0
  21. data/app/lib/panda_pal/lti_jwt_validator.rb +0 -0
  22. data/app/models/panda_pal/api_call.rb +0 -0
  23. data/app/models/panda_pal/organization.rb +0 -0
  24. data/app/models/panda_pal/organization_concerns/organization_builder.rb +0 -0
  25. data/app/models/panda_pal/organization_concerns/settings_validation.rb +0 -0
  26. data/app/models/panda_pal/organization_concerns/task_scheduling.rb +0 -0
  27. data/app/models/panda_pal/panda_pal_record.rb +0 -0
  28. data/app/models/panda_pal/platform/canvas.rb +0 -0
  29. data/app/models/panda_pal/platform.rb +0 -0
  30. data/app/models/panda_pal/session.rb +37 -14
  31. data/app/views/layouts/panda_pal/application.html.erb +0 -0
  32. data/app/views/panda_pal/lti/launch.html.erb +0 -0
  33. data/app/views/panda_pal/lti_v1_p3/login.html.erb +0 -0
  34. data/app/views/panda_pal/partials/_auto_submit_form.html.erb +0 -0
  35. data/config/dev_lti_key.key +0 -0
  36. data/config/initializers/apartment.rb +0 -0
  37. data/config/routes.rb +0 -0
  38. data/db/migrate/20160412205931_create_panda_pal_organizations.rb +0 -0
  39. data/db/migrate/20160413135653_create_panda_pal_sessions.rb +0 -0
  40. data/db/migrate/20160425130344_add_panda_pal_organization_to_session.rb +0 -0
  41. data/db/migrate/20170106165533_add_salesforce_id_to_organizations.rb +0 -0
  42. data/db/migrate/20171205183457_encrypt_organization_settings.rb +0 -0
  43. data/db/migrate/20171205194657_remove_old_organization_settings.rb +0 -0
  44. data/db/migrate/20220721095653_create_panda_pal_api_calls.rb +0 -0
  45. data/lib/panda_pal/concerns/ability_helper.rb +0 -0
  46. data/lib/panda_pal/engine.rb +0 -0
  47. data/lib/panda_pal/helpers/console_helpers.rb +0 -0
  48. data/lib/panda_pal/helpers/controller_helper.rb +0 -0
  49. data/lib/panda_pal/helpers/misc_helper.rb +0 -0
  50. data/lib/panda_pal/helpers/route_helper.rb +0 -0
  51. data/lib/panda_pal/helpers/secure_headers.rb +0 -0
  52. data/lib/panda_pal/helpers/session_replacement.rb +0 -0
  53. data/lib/panda_pal/helpers.rb +0 -0
  54. data/lib/panda_pal/plugins.rb +0 -0
  55. data/lib/panda_pal/version.rb +1 -1
  56. data/lib/panda_pal.rb +1 -1
  57. data/lib/tasks/panda_pal_tasks.rake +0 -0
  58. data/panda_pal.gemspec +0 -0
  59. data/spec/controllers/panda_pal/api_call_controller_spec.rb +0 -0
  60. data/spec/dummy/README.rdoc +0 -0
  61. data/spec/dummy/Rakefile +0 -0
  62. data/spec/dummy/app/assets/javascripts/application.js +0 -0
  63. data/spec/dummy/app/assets/stylesheets/application.css +0 -0
  64. data/spec/dummy/app/controllers/application_controller.rb +0 -0
  65. data/spec/dummy/app/helpers/application_helper.rb +0 -0
  66. data/spec/dummy/app/views/layouts/application.html.erb +0 -0
  67. data/spec/dummy/config/application.rb +0 -0
  68. data/spec/dummy/config/boot.rb +0 -0
  69. data/spec/dummy/config/database.yml +0 -0
  70. data/spec/dummy/config/environment.rb +0 -0
  71. data/spec/dummy/config/environments/development.rb +0 -0
  72. data/spec/dummy/config/environments/production.rb +0 -0
  73. data/spec/dummy/config/environments/test.rb +0 -0
  74. data/spec/dummy/config/initializers/backtrace_silencers.rb +0 -0
  75. data/spec/dummy/config/initializers/cookies_serializer.rb +0 -0
  76. data/spec/dummy/config/initializers/filter_parameter_logging.rb +0 -0
  77. data/spec/dummy/config/initializers/inflections.rb +0 -0
  78. data/spec/dummy/config/initializers/mime_types.rb +0 -0
  79. data/spec/dummy/config/initializers/session_store.rb +0 -0
  80. data/spec/dummy/config/initializers/wrap_parameters.rb +0 -0
  81. data/spec/dummy/config/locales/en.yml +0 -0
  82. data/spec/dummy/config/routes.rb +0 -0
  83. data/spec/dummy/config/secrets.yml +0 -0
  84. data/spec/dummy/config.ru +0 -0
  85. data/spec/dummy/db/schema.rb +0 -0
  86. data/spec/dummy/public/404.html +0 -0
  87. data/spec/dummy/public/422.html +0 -0
  88. data/spec/dummy/public/500.html +0 -0
  89. data/spec/dummy/public/favicon.ico +0 -0
  90. data/spec/factories/panda_pal_organizations.rb +0 -0
  91. data/spec/factories/panda_pal_sessions.rb +0 -0
  92. data/spec/models/panda_pal/api_call_spec.rb +0 -0
  93. data/spec/models/panda_pal/organization/settings_validation_spec.rb +0 -0
  94. data/spec/models/panda_pal/organization/task_scheduling_spec.rb +0 -0
  95. data/spec/models/panda_pal/organization_spec.rb +0 -0
  96. data/spec/models/panda_pal/session_spec.rb +0 -0
  97. data/spec/rails_helper.rb +0 -0
  98. data/spec/spec_helper.rb +0 -0
  99. metadata +37 -37
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 818ff98db4420d43b028102fcd6f44ee7e7413f0ca069fd65b44a8e84aab0545
4
- data.tar.gz: 923bdb90c19c89d0f3c1e4b98670ad8b495c68ee06cd872e2693f2881c96933d
3
+ metadata.gz: 75028dd065a6203af07a828ad23b78340b2b98c467ddc4def4b3935b6af31f15
4
+ data.tar.gz: dda65af42c0372f49c029508f9701093b99b81ca76c3cefa5448a35ba776031a
5
5
  SHA512:
6
- metadata.gz: e5631603f5e7dba2552404725dae8e512999d1b25bbdfa6ce0bef3923c7698cbcb3e093f88d1d6ed8126804565c183723bac95bb3e585e9518059f4850a8e2df
7
- data.tar.gz: 9af697df195ccb74891fef30a435de24b3c0099af4432cef4e5905f6ab4f12a0f33e80312af78259911ef200dd64586eb33954c83adcf8c541342183e3301282
6
+ metadata.gz: 911ca0334b047224f269121dd0a65e363c6239d763b73ef7ada18c439a66f29a11c51eae57ca1edfa8ffe18aa6b88bd7677aa41a5239c3517a2bc286668d30be
7
+ data.tar.gz: 25e362c44747b95d1316bec3c50ed508d6bf125a4b62328d1bc0c1a5bc1a498013d67db896422ff2e526ce111a29338f02481972b0a2fbe28d743baa4015ac07
data/MIT-LICENSE CHANGED
File without changes
data/README.md CHANGED
@@ -57,34 +57,32 @@ Use one of these 6 options in `PandaPal.lti_options` hash.
57
57
  ### Task Scheduling
58
58
  `PandaPal` includes an integration with `sidekiq-scheduler`. You can define tasks on an Organization class Stub like so:
59
59
  ```ruby
60
- # <your_app>/app/models/panda_pal/organization.rb
61
- require File.expand_path('../../app/models/panda_pal/organization.rb', PandaPal::Engine.called_from)
60
+ # <your_app>/app/models/organization_extension.rb
61
+ module OrganizationExtension
62
+ extend ActiveSupport::Concern
62
63
 
63
- module PandaPal
64
- class Organization
65
- # Will invoke CanvasSyncStarterWorker.perform_async() according to the cron schedule
66
- scheduled_task '0 15 05 * * *', :identifier, worker: CanvasSyncStarterWorker
64
+ # Will invoke CanvasSyncStarterWorker.perform_async() according to the cron schedule
65
+ scheduled_task '0 15 05 * * *', :identifier, worker: CanvasSyncStarterWorker
67
66
 
68
- # Will invoke the method 'organization_method' on the Organization
69
- scheduled_task '0 15 05 * * *', :organization_method_and_identifier
67
+ # Will invoke the method 'organization_method' on the Organization
68
+ scheduled_task '0 15 05 * * *', :organization_method_and_identifier
70
69
 
71
- # If you need to invoke the same method on multiple schedules
72
- scheduled_task '0 15 05 * * *', :identifier, worker: :organization_method
70
+ # If you need to invoke the same method on multiple schedules
71
+ scheduled_task '0 15 05 * * *', :identifier, worker: :organization_method
73
72
 
74
- # You can also use a block
75
- scheduled_task '0 15 05 * * *', :identifier do
76
- # Do Stuff
77
- end
73
+ # You can also use a block
74
+ scheduled_task '0 15 05 * * *', :identifier do
75
+ # Do Stuff
76
+ end
78
77
 
79
- # You can use a Proc (called in the context of the Organization) to determine the schedule
80
- scheduled_task -> { settings[:cron] }, :identifier
78
+ # You can use a Proc (called in the context of the Organization) to determine the schedule
79
+ scheduled_task -> { settings[:cron] }, :identifier
81
80
 
82
- # You can specify a timezone. If a TZ is not coded and settings[:timezone] is present, it will be appended automatically
83
- scheduled_task '0 15 05 * * * America/Denver', :identifier, worker: :organization_method
81
+ # You can specify a timezone. If a TZ is not coded and settings[:timezone] is present, it will be appended automatically
82
+ scheduled_task '0 15 05 * * * America/Denver', :identifier, worker: :organization_method
84
83
 
85
- # Setting settings[:task_schedules][:identifier] will override the code cron schedule. Setting it to false will disable the Task
86
- # :identifer values _must_ be unique, but can be nil, in which case they will be determined by where (lineno etc) scheduled_task is called
87
- end
84
+ # Setting settings[:task_schedules][:identifier] will override the code cron schedule. Setting it to false will disable the Task
85
+ # :identifer values _must_ be unique, but can be nil, in which case they will be determined by where (lineno etc) scheduled_task is called
88
86
  end
89
87
  ```
90
88
 
data/Rakefile CHANGED
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
@@ -10,6 +10,7 @@ module PandaPal
10
10
 
11
11
  before_action :validate_launch!, only: [:resource_link_request]
12
12
  around_action :switch_tenant, only: [:resource_link_request]
13
+ before_action :enforce_environment!, only: [:resource_link_request]
13
14
 
14
15
  # Redirect to beta/test as necessary
15
16
  before_action :forward_to_env_and_region, only: [:login]
@@ -19,6 +20,8 @@ module PandaPal
19
20
 
20
21
  current_session_data[:lti_platform] = @current_lti_platform&.serialize
21
22
  current_session_data[:lti_oauth_nonce] = SecureRandom.uuid
23
+ current_session_data[:canvas_environment] = params['canvas_environment']
24
+ current_session_data[:canvas_region] = params['canvas_region']
22
25
  current_session.panda_pal_organization_id = -1
23
26
 
24
27
  @form_action = current_lti_platform.authentication_redirect_url
@@ -128,7 +131,7 @@ module PandaPal
128
131
  if (canvas_env = params['canvas_environment']).present?
129
132
  tdomain = PandaPal.lti_environments[:"#{canvas_env}_domain"]
130
133
 
131
- if tdomain.present? && !request.url.include?(tdomain)
134
+ if tdomain.present? && !request.url.include?(tdomain) && PandaPal.lti_environments[:domain].present?
132
135
  return url.gsub(PandaPal.lti_environments[:domain], tdomain)
133
136
  end
134
137
  end
@@ -136,6 +139,17 @@ module PandaPal
136
139
  url
137
140
  end
138
141
 
142
+ def enforce_environment!
143
+ canvas_env = current_session_data[:canvas_environment]
144
+ return unless canvas_env.present?
145
+
146
+ org_canvas_url = current_organization.canvas_url
147
+
148
+ if (canvas_env == 'beta' || canvas_env == 'test') && org_canvas_url.present && !org_canvas_url.include?(".#{canvas_env}.")
149
+ render plain: "This tool is not properly configured for use in #{canvas_env}", status: 400
150
+ end
151
+ end
152
+
139
153
  private
140
154
 
141
155
  def auth_redirect_query
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
@@ -42,24 +42,39 @@ module PandaPal
42
42
  end
43
43
 
44
44
  def custom_lti_params
45
- # LT 1.3
46
- custom_params = launch_params["https://purl.imsglobal.org/spec/lti/claim/custom"]
47
- return custom_params if custom_params.present?
48
-
49
- # LTI 1.0/1.1
50
- custom_params = {}
51
- launch_params.each do |k, v|
52
- next unless k.start_with?("custom_")
53
- custom_params[k[7..-1]] = v
54
- end
45
+ @custom_lti_params ||= begin
46
+ # LT 1.3
47
+ custom_params = launch_params["https://purl.imsglobal.org/spec/lti/claim/custom"]
48
+ return custom_params if custom_params.present?
49
+
50
+ # LTI 1.0/1.1
51
+ custom_params = {}
52
+ launch_params.each do |k, v|
53
+ next unless k.start_with?("custom_")
54
+ custom_params[k[7..-1]] = v
55
+ end
55
56
 
56
- custom_params.with_indifferent_access
57
+ custom_params.with_indifferent_access
58
+ end
57
59
  end
58
60
 
59
- def get_lti_cust_param(key)
61
+ def get_lti_cust_param(key, default: :if_not_var)
60
62
  nkey = key.to_s.gsub(/^custom_/, '')
63
+ default_value = ->() { PandaPal.lti_custom_params[nkey] || PandaPal.lti_custom_params["custom_#{nkey}"] }
61
64
 
62
- launch_params.dig("https://purl.imsglobal.org/spec/lti/claim/custom", nkey) || launch_params[nkey] || launch_params["custom_#{nkey}"]
65
+ val = launch_params.dig("https://purl.imsglobal.org/spec/lti/claim/custom", nkey) || launch_params[nkey] || launch_params["custom_#{nkey}"]
66
+
67
+ if default == :if_not_var
68
+ if val.is_a?(String) && /\$[\.\w]+/.match?(val) && val == default_value[]
69
+ return nil
70
+ end
71
+ elsif default && !val.present?
72
+ return default_value[]
73
+ elsif !default && val == default_value[]
74
+ return nil
75
+ end
76
+
77
+ val
63
78
  end
64
79
 
65
80
  def canvas_role_labels
@@ -71,7 +86,7 @@ module PandaPal
71
86
  account = 'self' if account.to_s == "root"
72
87
  account = account.canvas_id if account.respond_to?(:canvas_id)
73
88
 
74
- if "::Admin".safe_constantize && ::Admin < ::ActiveRecord::Base
89
+ if defined?(::Admin) && ::Admin < ::ActiveRecord::Base
75
90
  account = current_organization.canvas_account_id if account == 'self'
76
91
  adm_query = ::Admin.where(canvas_account_id: account, workflow_state: "active")
77
92
  adm_query.pluck(:role_name)
@@ -88,6 +103,14 @@ module PandaPal
88
103
  @lti_roles ||= RoleStore.new(launch_params["https://purl.imsglobal.org/spec/lti/claim/roles"] || launch_params['ext_roles'] || '')
89
104
  end
90
105
 
106
+ def canvas_user_id
107
+ get_lti_cust_param('canvas_user_id')
108
+ end
109
+
110
+ def user
111
+ @user ||= ::User.find_by(canvas_id: canvas_user_id) if defined?(::User) && ::User < ::ActiveRecord::Base
112
+ end
113
+
91
114
  def canvas_site_admin?
92
115
  lti_roles.system_roles.include?("sys_admin")
93
116
  end
File without changes
File without changes
File without changes
File without changes
File without changes
data/config/routes.rb CHANGED
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
@@ -1,3 +1,3 @@
1
1
  module PandaPal
2
- VERSION = "5.10.0"
2
+ VERSION = "5.11.0"
3
3
  end
data/lib/panda_pal.rb CHANGED
@@ -43,7 +43,7 @@ module PandaPal
43
43
  end
44
44
 
45
45
  def self.lti_custom_params=(custom_params)
46
- @@lti_custom_params = custom_params
46
+ @@lti_custom_params = custom_params.with_indifferent_access
47
47
  end
48
48
 
49
49
  def self.lti_custom_params
File without changes
data/panda_pal.gemspec CHANGED
File without changes
File without changes
data/spec/dummy/Rakefile CHANGED
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
data/spec/dummy/config.ru CHANGED
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
data/spec/rails_helper.rb CHANGED
File without changes
data/spec/spec_helper.rb CHANGED
File without changes
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: panda_pal
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.10.0
4
+ version: 5.11.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Instructure CustomDev
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-05-30 00:00:00.000000000 Z
11
+ date: 2024-10-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -409,52 +409,52 @@ required_rubygems_version: !ruby/object:Gem::Requirement
409
409
  - !ruby/object:Gem::Version
410
410
  version: '0'
411
411
  requirements: []
412
- rubygems_version: 3.1.6
412
+ rubygems_version: 3.0.3.1
413
413
  signing_key:
414
414
  specification_version: 4
415
415
  summary: LTI mountable engine
416
416
  test_files:
417
- - spec/rails_helper.rb
418
- - spec/models/panda_pal/api_call_spec.rb
419
- - spec/models/panda_pal/organization_spec.rb
420
- - spec/models/panda_pal/session_spec.rb
421
- - spec/models/panda_pal/organization/settings_validation_spec.rb
422
- - spec/models/panda_pal/organization/task_scheduling_spec.rb
423
- - spec/controllers/panda_pal/api_call_controller_spec.rb
424
417
  - spec/spec_helper.rb
425
- - spec/dummy/db/schema.rb
426
- - spec/dummy/public/422.html
427
- - spec/dummy/public/favicon.ico
428
- - spec/dummy/public/404.html
429
- - spec/dummy/public/500.html
430
- - spec/dummy/Rakefile
431
- - spec/dummy/app/views/layouts/application.html.erb
432
418
  - spec/dummy/app/controllers/application_controller.rb
433
- - spec/dummy/app/helpers/application_helper.rb
434
- - spec/dummy/app/assets/stylesheets/application.css
419
+ - spec/dummy/app/views/layouts/application.html.erb
435
420
  - spec/dummy/app/assets/javascripts/application.js
421
+ - spec/dummy/app/assets/stylesheets/application.css
422
+ - spec/dummy/app/helpers/application_helper.rb
423
+ - spec/dummy/bin/rake
424
+ - spec/dummy/bin/setup
425
+ - spec/dummy/bin/bundle
426
+ - spec/dummy/bin/rails
436
427
  - spec/dummy/config/secrets.yml
437
- - spec/dummy/config/application.rb
438
- - spec/dummy/config/initializers/session_store.rb
439
- - spec/dummy/config/initializers/wrap_parameters.rb
440
- - spec/dummy/config/initializers/inflections.rb
441
- - spec/dummy/config/initializers/filter_parameter_logging.rb
442
- - spec/dummy/config/initializers/mime_types.rb
443
- - spec/dummy/config/initializers/backtrace_silencers.rb
444
- - spec/dummy/config/initializers/cookies_serializer.rb
428
+ - spec/dummy/config/routes.rb
429
+ - spec/dummy/config/locales/en.yml
430
+ - spec/dummy/config/environments/production.rb
445
431
  - spec/dummy/config/environments/development.rb
446
432
  - spec/dummy/config/environments/test.rb
447
- - spec/dummy/config/environments/production.rb
433
+ - spec/dummy/config/environment.rb
434
+ - spec/dummy/config/application.rb
448
435
  - spec/dummy/config/database.yml
449
436
  - spec/dummy/config/boot.rb
450
- - spec/dummy/config/routes.rb
451
- - spec/dummy/config/environment.rb
452
- - spec/dummy/config/locales/en.yml
453
- - spec/dummy/README.rdoc
437
+ - spec/dummy/config/initializers/backtrace_silencers.rb
438
+ - spec/dummy/config/initializers/mime_types.rb
439
+ - spec/dummy/config/initializers/filter_parameter_logging.rb
440
+ - spec/dummy/config/initializers/session_store.rb
441
+ - spec/dummy/config/initializers/wrap_parameters.rb
442
+ - spec/dummy/config/initializers/cookies_serializer.rb
443
+ - spec/dummy/config/initializers/inflections.rb
454
444
  - spec/dummy/config.ru
455
- - spec/dummy/bin/bundle
456
- - spec/dummy/bin/rake
457
- - spec/dummy/bin/setup
458
- - spec/dummy/bin/rails
459
- - spec/factories/panda_pal_organizations.rb
445
+ - spec/dummy/Rakefile
446
+ - spec/dummy/public/favicon.ico
447
+ - spec/dummy/public/422.html
448
+ - spec/dummy/public/500.html
449
+ - spec/dummy/public/404.html
450
+ - spec/dummy/db/schema.rb
451
+ - spec/dummy/README.rdoc
452
+ - spec/models/panda_pal/organization/settings_validation_spec.rb
453
+ - spec/models/panda_pal/organization/task_scheduling_spec.rb
454
+ - spec/models/panda_pal/session_spec.rb
455
+ - spec/models/panda_pal/api_call_spec.rb
456
+ - spec/models/panda_pal/organization_spec.rb
460
457
  - spec/factories/panda_pal_sessions.rb
458
+ - spec/factories/panda_pal_organizations.rb
459
+ - spec/controllers/panda_pal/api_call_controller_spec.rb
460
+ - spec/rails_helper.rb