Module: PandaPal
- Defined in:
- lib/panda_pal.rb,
lib/panda_pal/engine.rb,
lib/panda_pal/version.rb,
lib/panda_pal/lti_constants.rb,
app/models/panda_pal/session.rb,
app/models/panda_pal/api_call.rb,
app/models/panda_pal/platform.rb,
app/models/panda_pal/organization.rb,
lib/panda_pal/helpers/misc_helper.rb,
app/lib/panda_pal/lti_jwt_validator.rb,
app/lib/panda_pal/launch_url_helpers.rb,
app/models/panda_pal/platform/canvas.rb,
lib/panda_pal/helpers/secure_headers.rb,
app/models/panda_pal/panda_pal_record.rb,
lib/panda_pal/helpers/console_helpers.rb,
app/lib/panda_pal/deep_linking_helpers.rb,
app/controllers/panda_pal/lti_controller.rb,
app/helpers/panda_pal/application_helper.rb,
app/controllers/panda_pal/api_call_controller.rb,
app/controllers/panda_pal/lti_v1_p0_controller.rb,
app/controllers/panda_pal/lti_v1_p3_controller.rb,
app/controllers/panda_pal/panda_pal_controller.rb,
app/models/panda_pal/organization_concerns/task_scheduling.rb,
app/models/panda_pal/organization_concerns/task_scheduling.rb,
app/models/panda_pal/organization_concerns/tenant_handling.rb,
app/models/panda_pal/organization_concerns/settings_validation.rb,
app/models/panda_pal/organization_concerns/organization_builder.rb,
app/models/panda_pal/organization_concerns/multi_database_sharding.rb
Defined Under Namespace
Modules: ApplicationHelper, Concerns, ConsoleHelpers, DeepLinkingHelpers, Helpers, Jobs, LaunchUrlHelpers, LtiConstants, MiscHelper, OrganizationConcerns, Plugins, SecureHeaders, SkipSymmetricEncAttrEncrypted, SpecHelper
Classes: ApiCall, ApiCallController, Engine, LtiController, LtiJwtValidator, LtiNavigationInUse, LtiV1P0Controller, LtiV1P3Controller, NotMounted, Organization, PandaPalController, PandaPalRecord, Platform, Session, SettingsMarshaler
Constant Summary
collapse
- VERSION =
'5.16.13'
- @@lti_navigation =
{}
- @@lti_options =
{}
- @@lti_properties =
{}
- @@lti_environments =
{}
- @@lti_custom_params =
{}
- @@extensions =
{}
- @@lti_private_key =
nil
Class Method Summary
collapse
Class Method Details
.extensions_for(type) ⇒ Object
106
107
108
|
# File 'lib/panda_pal.rb', line 106
def self.extensions_for(type)
(@@extensions[normalize_ext_type(type)] || []).uniq
end
|
.jwk ⇒ Object
116
117
118
|
# File 'lib/panda_pal.rb', line 116
def self.jwk
@@jwk ||= JWT::JWK.new(lti_private_key, { use: 'sig', alg: 'RS256' })
end
|
.jwk=(v) ⇒ Object
120
121
122
|
# File 'lib/panda_pal.rb', line 120
def self.jwk=(v)
@@jwk = v
end
|
.lti_custom_params ⇒ Object
52
53
54
|
# File 'lib/panda_pal.rb', line 52
def self.lti_custom_params
@@lti_custom_params.deep_dup
end
|
.lti_custom_params=(custom_params) ⇒ Object
48
49
50
|
# File 'lib/panda_pal.rb', line 48
def self.lti_custom_params=(custom_params)
@@lti_custom_params = custom_params.with_indifferent_access
end
|
.lti_environments ⇒ Object
44
45
46
|
# File 'lib/panda_pal.rb', line 44
def self.lti_environments
@@lti_environments.deep_dup
end
|
.lti_environments=(lti_environments) ⇒ Object
40
41
42
|
# File 'lib/panda_pal.rb', line 40
def self.lti_environments=(lti_environments)
@@lti_environments = lti_environments
end
|
.lti_options ⇒ Object
28
29
30
|
# File 'lib/panda_pal.rb', line 28
def self.lti_options
@@lti_options.deep_dup
end
|
.lti_options=(lti_options) ⇒ Object
24
25
26
|
# File 'lib/panda_pal.rb', line 24
def self.lti_options= lti_options
@@lti_options = lti_options
end
|
.lti_paths ⇒ Object
74
75
76
|
# File 'lib/panda_pal.rb', line 74
def self.lti_paths
@@lti_navigation.deep_dup
end
|
.lti_private_key ⇒ Object
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
|
# File 'lib/panda_pal.rb', line 78
def self.lti_private_key
key = @@lti_private_key.presence
key ||= ENV['LTI_PRIVATE_KEY'].presence
if key.blank? && ENV['LTI_PRIVATE_KEY_PATH'].present?
key_path = File.expand_path(ENV['LTI_PRIVATE_KEY_PATH'], Rails.root)
key = File.read(key_path) if File.exist?(key_path)
end
key ||= File.read(File.join( File.dirname(__FILE__), "../config/dev_lti_key.key")) if Rails.env.development?
return nil unless key.present?
return key unless key.is_a?(String)
password = ENV['LTI_PRIVATE_KEY_PASSWORD']
OpenSSL::PKey::RSA.new(key, password)
end
|
.lti_private_key=(v) ⇒ Object
96
97
98
|
# File 'lib/panda_pal.rb', line 96
def self.lti_private_key=(v)
@@lti_private_key = v
end
|
.lti_properties ⇒ Object
36
37
38
|
# File 'lib/panda_pal.rb', line 36
def self.lti_properties
@@lti_properties.deep_dup
end
|
.lti_properties=(lti_properties) ⇒ Object
32
33
34
|
# File 'lib/panda_pal.rb', line 32
def self.lti_properties= lti_properties
@@lti_properties = lti_properties
end
|
.normalize_ext_type(type) ⇒ Object
126
127
128
129
130
|
# File 'lib/panda_pal.rb', line 126
def self.normalize_ext_type(type)
type = type.to_s
type = "#{self.to_s}::#{type}" unless type.start_with?('::') || type.start_with?(self.to_s)
type
end
|
.register_extension(type, modul) ⇒ Object
100
101
102
103
104
|
# File 'lib/panda_pal.rb', line 100
def self.register_extension(type, modul)
type = normalize_ext_type(type)
@@extensions[type] ||= []
@@extensions[type] << modul.to_s
end
|
.resolved_extensions_for(type) ⇒ Object
110
111
112
113
114
|
# File 'lib/panda_pal.rb', line 110
def self.resolved_extensions_for(type)
extensions_for(type).map do |ext|
ext.safe_constantize
end.compact
end
|
.stage_navigation(navigation, options = {}) ⇒ Object
56
57
58
59
|
# File 'lib/panda_pal.rb', line 56
def self.stage_navigation(navigation, options = {})
warn "[DEPRECATION] `stage_navigation` is deprecated. Please use `stage_placement` instead."
stage_placement(navigation, options)
end
|
.stage_placement(placement, options = {}) ⇒ Object
61
62
63
64
65
66
67
68
69
70
71
72
|
# File 'lib/panda_pal.rb', line 61
def self.stage_placement(placement, options = {})
@@lti_navigation[placement] ||= {}
if options.delete(:deep_linking)
options = options.merge({
message_type: LtiConstants::MessageTypes::DEEP_LINKING_REQUEST,
route_helper_key: :deep_link_request
})
end
@@lti_navigation[placement].merge!(options)
end
|
.validate_lti_navigation(errors = []) ⇒ Object
141
142
143
144
145
146
147
|
# File 'lib/panda_pal.rb', line 141
def self.validate_lti_navigation(errors = [])
@@lti_navigation.each do |k, v|
next if v[:route_helper_key]
errors << "lti navigation '#{k}' does not have a Route!" unless (LaunchUrlHelpers.launch_url(k) rescue nil)
end
errors
end
|
.validate_pandapal_config! ⇒ Object
132
133
134
135
136
137
138
139
|
# File 'lib/panda_pal.rb', line 132
def self.validate_pandapal_config!
errors = []
validate_lti_navigation(errors)
if errors.present?
lines = errors.map { |e| " - #{e}" }
raise "PandaPal was not configured correctly:\n#{lines.join("\n")}"
end
end
|