zuora_connect 2.0.1 → 2.0.3a
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
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1ea099d366f787567f8dd94e3023be8b615600ecd9d235c2f1ceb272a6edb934
|
4
|
+
data.tar.gz: d37e876aff4a42024af04b671b1c2ff8ca1b6916e3668e920e926e007bc08e12
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4735b01928f85f14c2e59d5d6e5a64d93329303555db4718f63d8974d69859186976a3fc359215b2e7eb082a100a002347992efd599e3d10bfe7b6916201bea3
|
7
|
+
data.tar.gz: e72e3c06379e3cba15828da615fc5116d1e44d1234852c490463815e71385a104134a2997ed2ac7feda2821057fd312a2af0873fad19b91a9df52d969a1515a3
|
@@ -17,6 +17,8 @@ module ZuoraConnect
|
|
17
17
|
HOLDING_PATTERN_SLEEP = 5.seconds
|
18
18
|
CONNECT_COMMUNICATION_SLEEP= 5.seconds
|
19
19
|
IGNORED_LOCALS = ['fr', 'ja', 'sp']
|
20
|
+
INTERNAL_HOSTS = []
|
21
|
+
LOGIN_TENANT_DESTINATION = 'target_login'
|
20
22
|
|
21
23
|
def init
|
22
24
|
self.connect_user = 'Nobody'
|
@@ -192,7 +194,14 @@ module ZuoraConnect
|
|
192
194
|
ElasticAPM.set_tag(:organization, organizations.first)
|
193
195
|
end
|
194
196
|
self.logitem(item: {tenant_ids: tenants, organization: organizations})
|
195
|
-
|
197
|
+
params = {
|
198
|
+
:name => self.task_data.dig('name'),
|
199
|
+
:zuora_domain => self.target_login.client.rest_domain,
|
200
|
+
:zuora_entity_ids => self.task_data.dig(LOGIN_TENANT_DESTINATION,'entities').map{|e| e['id']},
|
201
|
+
:zuora_tenant_ids => self.task_data['tenant_ids'],
|
202
|
+
}
|
203
|
+
params = params.reject{|k,v| !self.attributes.keys.member?(k.to_s) }
|
204
|
+
self.update_columns(params) if params.present?
|
196
205
|
end
|
197
206
|
|
198
207
|
def refresh(session: {}, session_fallback: false)
|
@@ -15,14 +15,45 @@ module ZuoraConnect
|
|
15
15
|
@appinstance = ZuoraConnect::AppInstance.where(:api_token => request.headers["API-Token"]).first
|
16
16
|
ZuoraConnect.logger.debug("[#{@appinstance.id}] API REQUEST - API token") if @appinstance.present?
|
17
17
|
check_instance
|
18
|
-
|
18
|
+
elsif ZuoraConnect::AppInstance::INTERNAL_HOSTS.include?(request.headers.fetch("HOST", nil))
|
19
|
+
zuora_host, zuora_entity_id, zuora_instance_id = [request.headers['zuora-host'], request.headers['zuora-entity-ids'].gsub('-',''), request.headers['zuora-instance-id']]
|
20
|
+
|
21
|
+
#Validate host present
|
22
|
+
if zuora_host.blank?
|
23
|
+
render json: {"status": 401, "message": "zuora-host header was not supplied."}, status: :unauthorized
|
24
|
+
return
|
25
|
+
end
|
26
|
+
#Validate entity-ids present
|
27
|
+
if zuora_entity_id.blank?
|
28
|
+
render json: {"status": 401, "message": "zuora-entity-ids header was not supplied."}, status: :unauthorized
|
29
|
+
return
|
30
|
+
end
|
31
|
+
#Select with instance id if present. Used where mulitple deployments are done.
|
32
|
+
if zuora_instance_id.present?
|
33
|
+
appinstances = ZuoraConnect::AppInstance.where("zuora_entity_ids ?& array[:entities] = true AND zuora_domain = :host AND id = :id", entities: [zuora_entity_id], host: zuora_host, id: zuora_instance_id)
|
34
|
+
else
|
35
|
+
appinstances = ZuoraConnect::AppInstance.where("zuora_entity_ids ?& array[:entities] = true AND zuora_domain = :host", entities: [zuora_entity_id], host: zuora_host)
|
36
|
+
end
|
37
|
+
|
38
|
+
if appinstances.size == 0
|
39
|
+
render json: {"status": 401, "message": "Missing mapping or no deployment for '#{zuora_host}-#{zuora_entity_id}' ."}, status: :unauthorized
|
40
|
+
elsif appinstances.size > 1
|
41
|
+
render json: {"status": 401, "message": "More than one app instance binded to host and entity ids. Please indicate correct instance via 'zuora-instance-id' header"}, status: :unauthorized
|
42
|
+
else
|
43
|
+
@appinstance = appinstances.first
|
44
|
+
end
|
45
|
+
|
46
|
+
elsif request.headers.fetch("Authorization", "").include?("Basic ")
|
19
47
|
authenticate_or_request_with_http_basic do |username, password|
|
20
48
|
@appinstance = ZuoraConnect::AppInstance.where(:token => password).first
|
21
49
|
@appinstance ||= ZuoraConnect::AppInstance.where(:api_token => password).first
|
22
50
|
ZuoraConnect.logger.debug("[#{@appinstance.id}] API REQUEST - Basic Auth") if @appinstance.present?
|
23
51
|
check_instance
|
24
52
|
end
|
53
|
+
else
|
54
|
+
check_instance
|
25
55
|
end
|
56
|
+
|
26
57
|
if @appinstance.present?
|
27
58
|
ZuoraConnect.logger.debug("[#{@appinstance.id}] Authenticate App API Request Completed In - #{(Time.now - start_time).round(2)}s")
|
28
59
|
end
|
@@ -243,7 +274,7 @@ module ZuoraConnect
|
|
243
274
|
|
244
275
|
#API ONLY
|
245
276
|
def check_instance
|
246
|
-
if @appinstance.present?
|
277
|
+
if defined?(@appinstance) && @appinstance.present?
|
247
278
|
if @appinstance.new_session_for_api_requests(:params => params)
|
248
279
|
@appinstance.new_session(:session => @appinstance.data_lookup(:session => session))
|
249
280
|
end
|
@@ -252,7 +283,9 @@ module ZuoraConnect
|
|
252
283
|
ElasticAPM.set_user("API User") if defined?(ElasticAPM) && ElasticAPM.running?
|
253
284
|
return true
|
254
285
|
else
|
255
|
-
|
286
|
+
response.set_header('WWW-Authenticate', "Basic realm=\"Application\"")
|
287
|
+
#render json: {"status": 401, "message": "Access Denied"}, status: :unauthorized
|
288
|
+
render text: "HTTP Basic: Access denied.\n", status: :unauthorized
|
256
289
|
end
|
257
290
|
end
|
258
291
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: zuora_connect
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.
|
4
|
+
version: 2.0.3a
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Connect Team
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-05-
|
11
|
+
date: 2019-05-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: apartment
|
@@ -44,20 +44,20 @@ dependencies:
|
|
44
44
|
requirements:
|
45
45
|
- - ">="
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: 1.6.
|
47
|
+
version: 1.6.37
|
48
48
|
- - "~>"
|
49
49
|
- !ruby/object:Gem::Version
|
50
|
-
version: 1.6.
|
50
|
+
version: 1.6.37
|
51
51
|
type: :runtime
|
52
52
|
prerelease: false
|
53
53
|
version_requirements: !ruby/object:Gem::Requirement
|
54
54
|
requirements:
|
55
55
|
- - ">="
|
56
56
|
- !ruby/object:Gem::Version
|
57
|
-
version: 1.6.
|
57
|
+
version: 1.6.37
|
58
58
|
- - "~>"
|
59
59
|
- !ruby/object:Gem::Version
|
60
|
-
version: 1.6.
|
60
|
+
version: 1.6.37
|
61
61
|
- !ruby/object:Gem::Dependency
|
62
62
|
name: httparty
|
63
63
|
requirement: !ruby/object:Gem::Requirement
|
@@ -407,9 +407,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
407
407
|
version: '0'
|
408
408
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
409
409
|
requirements:
|
410
|
-
- - "
|
410
|
+
- - ">"
|
411
411
|
- !ruby/object:Gem::Version
|
412
|
-
version:
|
412
|
+
version: 1.3.1
|
413
413
|
requirements: []
|
414
414
|
rubygems_version: 3.0.3
|
415
415
|
signing_key:
|