coalescing_panda 4.1.10 → 4.1.11
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
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 863946fbd5f47db0f0004cf6846111a0e95c4fd9
|
4
|
+
data.tar.gz: bf977dd224d2d2c6fbbbe49dca3ef9eb33d4ae99
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3138b812b0e8db4c16103f185660389e4c562624e756aa881931579de57cf608be9b1ad93e47e37a39d085a7bcff281ddd930f0e6b1aea0424af9e637e1cca0a
|
7
|
+
data.tar.gz: 05f9c464ac7f367ac2102697835c004f9446f8587ce73f7fa458432b22005b5ad4fd355d6527c3a432a37092f62aae0daf82e4b98e46a49a07b3e7ccf21da3de
|
@@ -13,7 +13,9 @@ module CoalescingPanda
|
|
13
13
|
client_key = lti_account.oauth2_client_key
|
14
14
|
user_id = params[:user_id]
|
15
15
|
api_domain = params[:api_domain]
|
16
|
-
|
16
|
+
prefix = [oauth2_protocol, '://', api_domain].join
|
17
|
+
Rails.logger.info "Creating Bearcat client for auth token retrieval pointed to: #{prefix}"
|
18
|
+
client = Bearcat::Client.new(prefix: prefix)
|
17
19
|
token = client.retrieve_token(client_id, coalescing_panda.oauth2_redirect_url, client_key, params['code'])
|
18
20
|
CanvasApiAuth.where('user_id = ? and api_domain = ?', user_id, api_domain).first_or_create do |auth|
|
19
21
|
auth.api_token = token
|
@@ -7,10 +7,7 @@ module CoalescingPanda
|
|
7
7
|
if lti_authorize!(*roles)
|
8
8
|
user_id = params['user_id']
|
9
9
|
launch_presentation_return_url = @lti_account.settings[:launch_presentation_return_url] || params['launch_presentation_return_url']
|
10
|
-
uri =
|
11
|
-
api_domain = uri.host
|
12
|
-
api_domain = "#{api_domain}:#{uri.port.to_s}" if uri.port
|
13
|
-
scheme = [uri.scheme, '://'].join
|
10
|
+
uri = BearcatURI.new(launch_presentation_return_url)
|
14
11
|
@lti_params = params.to_hash
|
15
12
|
session['user_id'] = user_id
|
16
13
|
session['uri'] = launch_presentation_return_url
|
@@ -18,15 +15,15 @@ module CoalescingPanda
|
|
18
15
|
session['oauth_consumer_key'] = params['oauth_consumer_key']
|
19
16
|
session['custom_canvas_account_id'] = params['custom_canvas_account_id']
|
20
17
|
|
21
|
-
if token = CanvasApiAuth.where('user_id = ? and api_domain = ?', user_id, api_domain).pluck(:api_token).first
|
22
|
-
@client = Bearcat::Client.new(token: token, prefix:
|
18
|
+
if token = CanvasApiAuth.where('user_id = ? and api_domain = ?', user_id, uri.api_domain).pluck(:api_token).first
|
19
|
+
@client = Bearcat::Client.new(token: token, prefix: uri.prefix)
|
23
20
|
elsif @lti_account = params['oauth_consumer_key'] && LtiAccount.find_by_key(params['oauth_consumer_key'])
|
24
21
|
client_id = @lti_account.oauth2_client_id
|
25
|
-
client = Bearcat::Client.new(prefix:
|
22
|
+
client = Bearcat::Client.new(prefix: uri.prefix)
|
26
23
|
session['state'] = SecureRandom.hex(32)
|
27
24
|
@canvas_url = client.auth_redirect_url(client_id,
|
28
25
|
coalescing_panda.oauth2_redirect_url({key: params['oauth_consumer_key'],
|
29
|
-
user_id: user_id, api_domain: api_domain, state: session['state']}))
|
26
|
+
user_id: user_id, api_domain: uri.api_domain, state: session['state']}))
|
30
27
|
#delete the added params so the original oauth sig still works
|
31
28
|
@lti_params.delete('action')
|
32
29
|
@lti_params.delete('controller')
|
@@ -43,12 +40,9 @@ module CoalescingPanda
|
|
43
40
|
end
|
44
41
|
|
45
42
|
if (session['user_id'] && session['uri'])
|
46
|
-
uri =
|
47
|
-
api_domain = uri.
|
48
|
-
|
49
|
-
scheme = uri.scheme + '://'
|
50
|
-
token = CanvasApiAuth.where('user_id = ? and api_domain = ?', session['user_id'], api_domain).pluck(:api_token).first
|
51
|
-
@client = Bearcat::Client.new(token: token, prefix: scheme+api_domain) if token
|
43
|
+
uri = BearcatURI.new(session['uri'])
|
44
|
+
token = CanvasApiAuth.where('user_id = ? and api_domain = ?', session['user_id'], uri.api_domain).pluck(:api_token).first
|
45
|
+
@client = Bearcat::Client.new(token: token, prefix: uri.prefix) if token
|
52
46
|
end
|
53
47
|
|
54
48
|
@lti_account = LtiAccount.find_by_key(session['oauth_consumer_key']) if session['oauth_consumer_key']
|
@@ -128,5 +122,26 @@ module CoalescingPanda
|
|
128
122
|
end
|
129
123
|
end
|
130
124
|
|
125
|
+
class BearcatURI
|
126
|
+
attr_accessor :uri
|
127
|
+
|
128
|
+
def initialize(uri)
|
129
|
+
Rails.logger.info "Parsing Bearcat URI: #{uri}"
|
130
|
+
@uri = URI.parse(uri)
|
131
|
+
end
|
132
|
+
|
133
|
+
def api_domain
|
134
|
+
uri.port.present? ? "#{uri.host}:#{uri.port.to_s}" : uri.host
|
135
|
+
end
|
136
|
+
|
137
|
+
def scheme
|
138
|
+
[uri.scheme, '://'].join
|
139
|
+
end
|
140
|
+
|
141
|
+
def prefix
|
142
|
+
[scheme, api_domain].join
|
143
|
+
end
|
144
|
+
end
|
145
|
+
|
131
146
|
end
|
132
147
|
end
|