zuora_connect 3.1.5.pre.g → 3.2.0
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: d04a0fdede87007e236c944ed42bfc822846276fce78a310d22bb89961ed6bee
|
|
4
|
+
data.tar.gz: fe5e370e36988531ff42f08e493a39118a9e0de078e3334df9c1a3c79ad3460f
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: c8836d2516b37c25dce916ed9f976a5bff9456254378301d7a2d5ca457b6d6fc778eb28a7d73d0c16f27f1adc683c12610f8f5b60461a962abae682a7e8d4a7c
|
|
7
|
+
data.tar.gz: e8f4bff78c8fd8160f5a681743cdefe108d0b9a8a3e4e1e6c96fc72b9990e13c27800d91e8dc3b23db008425d23d5d7d3c53f1473300f5d817dda38e48998332
|
|
@@ -519,7 +519,7 @@ module ZuoraConnect
|
|
|
519
519
|
rescue ArgumentError, OpenSSL::Cipher::CipherError => ex
|
|
520
520
|
if (
|
|
521
521
|
ex.is_a?(ArgumentError) && ['invalid base64', 'data must not be empty'].include?(ex.message) ||
|
|
522
|
-
|
|
522
|
+
ex.is_a?(OpenSSL::Cipher::CipherError) && ['wrong final block length', 'bad decrypt'].include?(ex.message)
|
|
523
523
|
) && encryption_type == :envelope && (kms_tries += 1) < 3
|
|
524
524
|
ZuoraConnect.logger.warn("Fallback to encryption 'direct', from '#{encryption_type}'", ex, self.default_ougai_items)
|
|
525
525
|
encryption_type = :direct
|
|
@@ -907,12 +907,6 @@ module ZuoraConnect
|
|
|
907
907
|
|
|
908
908
|
session["#{self.id}::last_refresh"] = self.last_refresh
|
|
909
909
|
session["appInstance"] = self.id
|
|
910
|
-
|
|
911
|
-
unless ZuoraConnect::ZuoraUser.current_org_child_org_ids.nil?
|
|
912
|
-
session["zuora_org_id"] = ZuoraConnect::ZuoraUser.current_org_id
|
|
913
|
-
session["zuora_org_child_org_ids"] = ZuoraConnect::ZuoraUser.current_org_child_org_ids
|
|
914
|
-
end
|
|
915
|
-
|
|
916
910
|
return session
|
|
917
911
|
end
|
|
918
912
|
|
|
@@ -66,39 +66,6 @@ module ZuoraConnect
|
|
|
66
66
|
end
|
|
67
67
|
|
|
68
68
|
@zuora_user = ZuoraConnect::ZuoraUser.find_by(zuora_user_id: ZuoraConnect::ZuoraUser.current_user_id)
|
|
69
|
-
|
|
70
|
-
zuora_org_id = request.headers["Zuora-Org-Id"]
|
|
71
|
-
zuora_return_nested_orgs_data = request.headers['Zuora-Return-Nested-Orgs-Data'].to_bool
|
|
72
|
-
ZuoraConnect::ZuoraUser.current_org_id = zuora_org_id
|
|
73
|
-
ZuoraConnect::ZuoraUser.current_org_child_org_ids = nil
|
|
74
|
-
|
|
75
|
-
if zuora_return_nested_orgs_data
|
|
76
|
-
cached_session = @appinstance.data_lookup(session: session)
|
|
77
|
-
|
|
78
|
-
if cached_session['zuora_org_id'] == ZuoraConnect::ZuoraUser.current_org_id &&
|
|
79
|
-
cached_session.key?('zuora_org_child_org_ids')
|
|
80
|
-
ZuoraConnect::ZuoraUser.current_org_child_org_ids = cached_session['zuora_org_child_org_ids']
|
|
81
|
-
else
|
|
82
|
-
begin
|
|
83
|
-
zuora_client = @appinstance.target_login.client
|
|
84
|
-
child_org_list, _ =
|
|
85
|
-
zuora_client.rest_call(
|
|
86
|
-
url: zuora_client.
|
|
87
|
-
rest_endpoint("tenant-registry/listChildOrgsForOrg/#{ZuoraConnect::ZuoraUser.current_org_id}").
|
|
88
|
-
gsub('v1/', ''),
|
|
89
|
-
session_type: zuora_client.is_a?(ZuoraAPI::Oauth) ? :bearer : :basic,
|
|
90
|
-
zuora_track_id: ZuoraConnect::RequestIdMiddleware.zuora_request_id
|
|
91
|
-
)
|
|
92
|
-
rescue ZuoraAPI::Exceptions::ZuoraAPIError => ex
|
|
93
|
-
if ex.message.include?('organization does not exist')
|
|
94
|
-
raise ZuoraConnect::Exceptions::OrganizationAccessForbidden
|
|
95
|
-
else
|
|
96
|
-
raise
|
|
97
|
-
end
|
|
98
|
-
end
|
|
99
|
-
ZuoraConnect::ZuoraUser.current_org_child_org_ids = child_org_list.map { |org| org['id'] }
|
|
100
|
-
end
|
|
101
|
-
end
|
|
102
69
|
end
|
|
103
70
|
end
|
|
104
71
|
|
|
@@ -260,6 +227,39 @@ module ZuoraConnect
|
|
|
260
227
|
return (request.headers['ZuoraCurrentEntity'].present? || cookies['ZuoraCurrentEntity'].present?)
|
|
261
228
|
end
|
|
262
229
|
|
|
230
|
+
def org_relation_mapping(root_org_relation)
|
|
231
|
+
relation = {}
|
|
232
|
+
|
|
233
|
+
return relation if root_org_relation.blank?
|
|
234
|
+
|
|
235
|
+
root_org_id = root_org_relation.dig(0, 'rootOrgId')
|
|
236
|
+
relation[root_org_id] = []
|
|
237
|
+
|
|
238
|
+
root_org_relation.each do |child_org|
|
|
239
|
+
relation[child_org['id']] = []
|
|
240
|
+
end
|
|
241
|
+
|
|
242
|
+
root_org_relation.each do |child_org|
|
|
243
|
+
parent_org_id = child_org['parentOrgId']
|
|
244
|
+
relation[parent_org_id].push(child_org['id'])
|
|
245
|
+
end
|
|
246
|
+
|
|
247
|
+
relation
|
|
248
|
+
end
|
|
249
|
+
|
|
250
|
+
def get_child_orgs_from_relation_mapping(relation_mapping, org_id)
|
|
251
|
+
if relation_mapping.blank? || org_id.blank? || relation_mapping[org_id].blank?
|
|
252
|
+
return []
|
|
253
|
+
end
|
|
254
|
+
|
|
255
|
+
child_orgs = relation_mapping[org_id].dup
|
|
256
|
+
relation_mapping[org_id].each do |child_org_id|
|
|
257
|
+
child_orgs += get_child_orgs_from_relation_mapping(relation_mapping, child_org_id)
|
|
258
|
+
end
|
|
259
|
+
|
|
260
|
+
child_orgs
|
|
261
|
+
end
|
|
262
|
+
|
|
263
263
|
def create_new_instance
|
|
264
264
|
ZuoraConnect::AppInstance.read_master_db do
|
|
265
265
|
Thread.current[:appinstance] = nil
|
|
@@ -595,35 +595,53 @@ module ZuoraConnect
|
|
|
595
595
|
cookies['Zuora-Return-Nested-Orgs-Data'].to_bool ||
|
|
596
596
|
request.headers['Zuora-Return-Nested-Orgs-Data'].to_bool
|
|
597
597
|
ZuoraConnect::ZuoraUser.current_org_id = zuora_org_id
|
|
598
|
-
ZuoraConnect::ZuoraUser.current_org_child_org_ids =
|
|
598
|
+
ZuoraConnect::ZuoraUser.current_org_child_org_ids = []
|
|
599
599
|
|
|
600
|
-
if zuora_return_nested_orgs_data
|
|
601
|
-
|
|
600
|
+
if zuora_org_id.present? && zuora_return_nested_orgs_data
|
|
601
|
+
cached_org_relationship = Redis.current.get("MultiOrgRelationship:#{@appinstance.id}")
|
|
602
602
|
|
|
603
|
-
if
|
|
604
|
-
|
|
605
|
-
ZuoraConnect::ZuoraUser.current_org_child_org_ids =
|
|
603
|
+
if cached_org_relationship.present?
|
|
604
|
+
cached_org_relationship = JSON.parse(cached_org_relationship)
|
|
605
|
+
ZuoraConnect::ZuoraUser.current_org_child_org_ids =
|
|
606
|
+
get_child_orgs_from_relation_mapping(cached_org_relationship, ZuoraConnect::ZuoraUser.current_org_id)
|
|
606
607
|
else
|
|
607
|
-
|
|
608
|
-
|
|
608
|
+
child_org_list, _ =
|
|
609
|
+
zuora_client.rest_call(
|
|
610
|
+
url: zuora_client.
|
|
611
|
+
rest_endpoint("tenant-registry/listChildOrgsForOrg/#{ZuoraConnect::ZuoraUser.current_org_id}").
|
|
612
|
+
gsub('v1/', ''),
|
|
613
|
+
session_type: zuora_client.is_a?(ZuoraAPI::Oauth) ? :bearer : :basic,
|
|
614
|
+
headers: auth_headers,
|
|
615
|
+
zuora_track_id: ZuoraConnect::RequestIdMiddleware.zuora_request_id
|
|
616
|
+
)
|
|
617
|
+
|
|
618
|
+
root_org_id = (child_org_list || {}).dig(0, 'rootOrgId').to_s
|
|
619
|
+
if root_org_id.present?
|
|
620
|
+
root_child_org_list, _ =
|
|
609
621
|
zuora_client.rest_call(
|
|
610
622
|
url: zuora_client.
|
|
611
|
-
rest_endpoint("tenant-registry/listChildOrgsForOrg/#{
|
|
623
|
+
rest_endpoint("tenant-registry/listChildOrgsForOrg/#{root_org_id}").
|
|
612
624
|
gsub('v1/', ''),
|
|
613
625
|
session_type: zuora_client.is_a?(ZuoraAPI::Oauth) ? :bearer : :basic,
|
|
614
626
|
headers: auth_headers,
|
|
615
627
|
zuora_track_id: ZuoraConnect::RequestIdMiddleware.zuora_request_id
|
|
616
628
|
)
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
629
|
+
|
|
630
|
+
org_relationship = org_relation_mapping(root_child_org_list)
|
|
631
|
+
Redis.current.setex(
|
|
632
|
+
"MultiOrgRelationship:#{@appinstance.id}",
|
|
633
|
+
1.day,
|
|
634
|
+
org_relationship.to_json
|
|
635
|
+
)
|
|
636
|
+
|
|
637
|
+
ZuoraConnect::ZuoraUser.current_org_child_org_ids =
|
|
638
|
+
get_child_orgs_from_relation_mapping(org_relationship, ZuoraConnect::ZuoraUser.current_org_id)
|
|
639
|
+
else
|
|
640
|
+
ZuoraConnect.logger.info("Failed to get root org id for #{@appinstance.id}")
|
|
623
641
|
end
|
|
624
|
-
ZuoraConnect::ZuoraUser.current_org_child_org_ids = child_org_list.map { |org| org['id'] }
|
|
625
642
|
end
|
|
626
643
|
end
|
|
644
|
+
|
|
627
645
|
rescue ZuoraAPI::Exceptions::ZuoraAPIAuthenticationTypeError => ex
|
|
628
646
|
output_xml, input_xml, response = zuora_client.soap_call(errors: [], z_session: false, zuora_track_id: ZuoraConnect::RequestIdMiddleware.zuora_request_id) do |xml|
|
|
629
647
|
xml['api'].getUserInfo
|
|
@@ -640,17 +658,6 @@ module ZuoraConnect
|
|
|
640
658
|
redirect_to "https://#{zuora_host}/apps/newlogin.do?retURL=#{request.fullpath}&pos=1"
|
|
641
659
|
return
|
|
642
660
|
|
|
643
|
-
rescue ZuoraConnect::Exceptions::OrganizationAccessForbidden => ex
|
|
644
|
-
locals = {
|
|
645
|
-
title: "You cannot operate with the current organization",
|
|
646
|
-
message: "Please switch the organization and try again"
|
|
647
|
-
}
|
|
648
|
-
respond_to do |format|
|
|
649
|
-
format.html { render "zuora_connect/static/error_handled", locals: locals, status: 403, layout: false }
|
|
650
|
-
format.js { render "zuora_connect/static/error_handled", locals: locals, status: 202, layout: false }
|
|
651
|
-
format.json { render json: {'errors' => ex.message}, status: 403 }
|
|
652
|
-
format.all { render json: ex.message, status: 403 }
|
|
653
|
-
end
|
|
654
661
|
rescue ZuoraAPI::Exceptions::ZuoraAPIError, Exception => ex
|
|
655
662
|
if ex.message.include?("Referenced User resource(s) not found") && ex.class == ZuoraAPI::Exceptions::ZuoraAPIError
|
|
656
663
|
locals = {title: "Provisioning Error", message: "New tenants need to be provisioned by API Gateway('#{ex.message}'). Please contact support."}
|
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: 3.
|
|
4
|
+
version: 3.2.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Connect Team
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2022-
|
|
11
|
+
date: 2022-12-23 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: apartment
|
|
@@ -452,9 +452,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
452
452
|
version: '0'
|
|
453
453
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
454
454
|
requirements:
|
|
455
|
-
- - "
|
|
455
|
+
- - ">="
|
|
456
456
|
- !ruby/object:Gem::Version
|
|
457
|
-
version:
|
|
457
|
+
version: '0'
|
|
458
458
|
requirements: []
|
|
459
459
|
rubygems_version: 3.3.7
|
|
460
460
|
signing_key:
|