coalescing_panda 5.0.2 → 5.0.3
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 306dfeeb30b6ae7918306493e16fad1153218caff10326e85e20767fe65e6939
|
4
|
+
data.tar.gz: 8e1d71edd52810dc203bffabc505f4bf1d594b9dd6a41af69850d00d9a7a49bf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c07375ac5edf196130f97ad74d87b78895c0c75ee22452b739932b525a5cb79a29e6e4a751ad0addf2e92782e466f4403ace209399245d5fb0d26f20764e892d
|
7
|
+
data.tar.gz: 923158157e37c46b0374ccebcd5b3c9dac3e7f70d2df759aa6f340fec35f4b179b2fc3fe8ac51babe7a95ea0f569ff066f07bd46ee536e5679ad89da3b77472e
|
@@ -0,0 +1,13 @@
|
|
1
|
+
module CoalescingPanda
|
2
|
+
class JSONWithIndifferentAccess
|
3
|
+
def self.load(str)
|
4
|
+
return nil unless str.present?
|
5
|
+
parsed = JSON.parse(str)
|
6
|
+
parsed.is_a?(Hash) ? HashWithIndifferentAccess.new(parsed) : parsed
|
7
|
+
end
|
8
|
+
|
9
|
+
def self.dump(obj)
|
10
|
+
JSON.dump(obj)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -1,10 +1,11 @@
|
|
1
1
|
module CoalescingPanda
|
2
2
|
class PersistentSession < ActiveRecord::Base
|
3
|
-
serialize :data,
|
3
|
+
serialize :data, JSONWithIndifferentAccess
|
4
4
|
belongs_to :coalescing_panda_lti_account, :class_name => 'CoalescingPanda::LtiAccount'
|
5
5
|
validates :coalescing_panda_lti_account_id, presence: true
|
6
6
|
|
7
7
|
after_initialize do
|
8
|
+
self.data ||= {}
|
8
9
|
self.session_key ||= SecureRandom.urlsafe_base64(60)
|
9
10
|
end
|
10
11
|
|
@@ -2,15 +2,32 @@ require 'browser'
|
|
2
2
|
|
3
3
|
module CoalescingPanda
|
4
4
|
module ControllerHelpers
|
5
|
+
extend ActiveSupport::Concern
|
6
|
+
|
7
|
+
included do
|
8
|
+
alias_method :rails_session, :session
|
9
|
+
|
10
|
+
helper_method :encrypted_session_key, :current_session_data, :current_session
|
11
|
+
append_after_action :save_session, if: -> { @current_session && session_changed? }
|
12
|
+
end
|
13
|
+
|
14
|
+
class_methods do
|
15
|
+
def use_native_sessions
|
16
|
+
after_action do
|
17
|
+
rails_session['persistent_session_key'] = current_session.session_key if @current_session.present?
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
5
22
|
def current_session
|
6
|
-
@current_session ||= CoalescingPanda::PersistentSession.find_by(session_key: session_key) if session_key
|
7
|
-
@current_session ||= CoalescingPanda::PersistentSession.create_from_launch(params, current_lti_account.id)
|
23
|
+
@current_session ||= (CoalescingPanda::PersistentSession.find_by(session_key: session_key) if session_key)
|
24
|
+
@current_session ||= (CoalescingPanda::PersistentSession.create_from_launch(params, current_lti_account.id) if current_lti_account.present?)
|
8
25
|
@current_session
|
9
26
|
end
|
10
27
|
|
11
28
|
def current_lti_account
|
12
|
-
@account ||= CoalescingPanda::LtiAccount.find_by!(key: organization_key) if organization_key
|
13
|
-
@account ||= CoalescingPanda::LtiAccount.find_by(id: organization_id) if organization_id
|
29
|
+
@account ||= (CoalescingPanda::LtiAccount.find_by!(key: organization_key) if organization_key)
|
30
|
+
@account ||= (CoalescingPanda::LtiAccount.find_by(id: organization_id) if organization_id)
|
14
31
|
@account
|
15
32
|
end
|
16
33
|
|
@@ -83,42 +100,42 @@ module CoalescingPanda
|
|
83
100
|
end
|
84
101
|
|
85
102
|
def check_refresh_token
|
86
|
-
return unless
|
87
|
-
uri = BearcatUri.new(
|
88
|
-
api_auth = CanvasApiAuth.find_by(user_id:
|
89
|
-
@lti_account = LtiAccount.find_by(key:
|
103
|
+
return unless current_session_data['uri'] && current_session_data['user_id'] && current_session_data['oauth_consumer_key']
|
104
|
+
uri = BearcatUri.new(current_session_data['uri'])
|
105
|
+
api_auth = CanvasApiAuth.find_by(user_id: current_session_data['user_id'], api_domain: uri.api_domain)
|
106
|
+
@lti_account = LtiAccount.find_by(key: current_session_data['oauth_consumer_key'])
|
90
107
|
return if @lti_account.nil? || api_auth.nil? # Not all tools use oauth
|
91
108
|
|
92
109
|
refresh_token(uri, api_auth) if api_auth.expired?
|
93
110
|
rescue Footrest::HttpError::BadRequest
|
94
|
-
render_oauth2_page uri,
|
111
|
+
render_oauth2_page uri, current_session_data['user_id']
|
95
112
|
end
|
96
113
|
|
97
114
|
def set_session(launch_presentation_return_url)
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
115
|
+
current_session_data['user_id'] = params['user_id']
|
116
|
+
current_session_data['uri'] = launch_presentation_return_url
|
117
|
+
current_session_data['lis_person_sourcedid'] = params['lis_person_sourcedid']
|
118
|
+
current_session_data['oauth_consumer_key'] = params['oauth_consumer_key']
|
119
|
+
current_session_data['custom_canvas_account_id'] = params['custom_canvas_account_id']
|
103
120
|
end
|
104
121
|
|
105
122
|
def have_session?
|
106
|
-
if params['tool_consumer_instance_guid'] &&
|
123
|
+
if params['tool_consumer_instance_guid'] && current_session_data['user_id'] != params['user_id']
|
107
124
|
reset_session
|
108
125
|
logger.info("resetting session params")
|
109
|
-
|
126
|
+
current_session_data['user_id'] = params['user_id']
|
110
127
|
end
|
111
128
|
|
112
|
-
if (
|
113
|
-
uri = BearcatUri.new(
|
114
|
-
api_auth = CanvasApiAuth.find_by('user_id = ? and api_domain = ?',
|
129
|
+
if (current_session_data['user_id'] && current_session_data['uri'])
|
130
|
+
uri = BearcatUri.new(current_session_data['uri'])
|
131
|
+
api_auth = CanvasApiAuth.find_by('user_id = ? and api_domain = ?', current_session_data['user_id'], uri.api_domain)
|
115
132
|
if api_auth && !api_auth.expired?
|
116
133
|
@client = Bearcat::Client.new(token: api_auth.api_token, prefix: uri.prefix)
|
117
134
|
@client.user_profile 'self'
|
118
135
|
end
|
119
136
|
end
|
120
137
|
|
121
|
-
@lti_account = LtiAccount.find_by_key(
|
138
|
+
@lti_account = LtiAccount.find_by_key(current_session_data['oauth_consumer_key']) if current_session_data['oauth_consumer_key']
|
122
139
|
|
123
140
|
!!@client
|
124
141
|
rescue Footrest::HttpError::Unauthorized
|
@@ -198,7 +215,7 @@ module CoalescingPanda
|
|
198
215
|
if params[:encrypted_session_key]
|
199
216
|
return msg_encryptor.decrypt_and_verify(params[:encrypted_session_key])
|
200
217
|
end
|
201
|
-
params[:session_key] || session_key_header
|
218
|
+
params[:session_key] || session_key_header || rails_session['persistent_session_key']
|
202
219
|
end
|
203
220
|
|
204
221
|
def session_key_header
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: coalescing_panda
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 5.0.
|
4
|
+
version: 5.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nathan Mills
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2020-07-
|
13
|
+
date: 2020-07-28 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rails
|
@@ -423,6 +423,7 @@ files:
|
|
423
423
|
- app/models/coalescing_panda/group.rb
|
424
424
|
- app/models/coalescing_panda/group_category.rb
|
425
425
|
- app/models/coalescing_panda/group_membership.rb
|
426
|
+
- app/models/coalescing_panda/json_with_indifferent_access.rb
|
426
427
|
- app/models/coalescing_panda/lti_account.rb
|
427
428
|
- app/models/coalescing_panda/lti_nonce.rb
|
428
429
|
- app/models/coalescing_panda/oauth_state.rb
|