zuora_connect 3.1.5.pre.g → 3.1.5
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 +4 -4
- data/app/controllers/zuora_connect/static_controller.rb +1 -6
- data/app/models/zuora_connect/app_instance_base.rb +2 -11
- data/app/models/zuora_connect/zuora_user.rb +1 -1
- data/lib/zuora_connect/configuration.rb +1 -2
- data/lib/zuora_connect/controllers/helpers.rb +1 -95
- data/lib/zuora_connect/exceptions.rb +0 -14
- data/lib/zuora_connect/version.rb +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3ce9871a6d530d5d0146cf591445fd21ec4f1cba986944b8b966ddc493c5f1a1
|
4
|
+
data.tar.gz: db1756a9a29035a6180ce3370021432a6b255567b8aeaea1eb36ad3f25651ff6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: aea09cd52f629f8feb5a57a2e200040ad0371a64086c15a662f3408f77ef930211dceb2b01ebbfecc7ca437f268b262a60f52f05d43a3b0ca17e830db72a7e63
|
7
|
+
data.tar.gz: b324ac9bd0f233b04e641efafc2e62e4344218c84f99005fbe67a31a301ececb56411966b67b7a7333ee6581500ee72af4780aea6fa7c58dc15abd60c29c8169
|
@@ -1,5 +1,4 @@
|
|
1
1
|
module ZuoraConnect
|
2
|
-
require "resolv"
|
3
2
|
class StaticController < ApplicationController
|
4
3
|
before_action :authenticate_connect_app_request, :except => [:health, :initialize_app, :provision, :instance_user, :instance_drop]
|
5
4
|
before_action :clear_connect_app_session, :only => [:health, :initialize_app, :provision, :instance_user, :instance_drop]
|
@@ -52,10 +51,6 @@ module ZuoraConnect
|
|
52
51
|
end
|
53
52
|
|
54
53
|
def provision
|
55
|
-
if ZuoraConnect.configuration.disable_provisioning
|
56
|
-
render(json: { status: 403, message: 'Provisioning is suspended' }, status: 403) && return
|
57
|
-
end
|
58
|
-
|
59
54
|
create_new_instance
|
60
55
|
unless performed?
|
61
56
|
render json: {
|
@@ -125,7 +120,7 @@ module ZuoraConnect
|
|
125
120
|
|
126
121
|
def instance_drop
|
127
122
|
host = request.headers.fetch("HOST", nil)
|
128
|
-
if host.present? &&
|
123
|
+
if host.present? && ZuoraConnect::AppInstance::INTERNAL_HOSTS.include?(host)
|
129
124
|
ZuoraConnect::AppInstance.read_master_db do
|
130
125
|
instance_id = params[:id]
|
131
126
|
@appinstance = ZuoraConnect::AppInstance.find(instance_id)
|
@@ -516,11 +516,8 @@ module ZuoraConnect
|
|
516
516
|
else
|
517
517
|
ZuoraConnect::Exceptions::Error.new("Invalid encryption method '#{encryption_type}'.")
|
518
518
|
end
|
519
|
-
rescue ArgumentError
|
520
|
-
if (
|
521
|
-
ex.is_a?(ArgumentError) && ['invalid base64', 'data must not be empty'].include?(ex.message) ||
|
522
|
-
ex.is_a?(OpenSSL::Cipher::CipherError) && ['wrong final block length', 'bad decrypt'].include?(ex.message)
|
523
|
-
) && encryption_type == :envelope && (kms_tries += 1) < 3
|
519
|
+
rescue ArgumentError => ex
|
520
|
+
if ex.message == 'invalid base64' && encryption_type == :envelope && (kms_tries += 1) < 3
|
524
521
|
ZuoraConnect.logger.warn("Fallback to encryption 'direct', from '#{encryption_type}'", ex, self.default_ougai_items)
|
525
522
|
encryption_type = :direct
|
526
523
|
retry
|
@@ -907,12 +904,6 @@ module ZuoraConnect
|
|
907
904
|
|
908
905
|
session["#{self.id}::last_refresh"] = self.last_refresh
|
909
906
|
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
907
|
return session
|
917
908
|
end
|
918
909
|
|
@@ -3,7 +3,7 @@ module ZuoraConnect
|
|
3
3
|
self.table_name = "zuora_users"
|
4
4
|
attr_accessor :session
|
5
5
|
|
6
|
-
cattr_accessor :current_user_id
|
6
|
+
cattr_accessor :current_user_id
|
7
7
|
|
8
8
|
# zuora_user_id/zuora_entity_id both come from cookie or headers
|
9
9
|
# zuora_current_identity comes from session
|
@@ -7,7 +7,7 @@ module ZuoraConnect
|
|
7
7
|
|
8
8
|
attr_accessor :oauth_client_id, :oauth_client_secret, :oauth_client_redirect_uri
|
9
9
|
|
10
|
-
attr_accessor :dev_mode_logins, :dev_mode_options, :dev_mode_mode, :dev_mode_appinstance, :dev_mode_user, :dev_mode_pass, :dev_mode_admin, :dev_mode_secret_access_key,:dev_mode_access_key_id,:aws_region, :s3_bucket_name, :s3_folder_name, :insert_migrations, :skip_connect, :encryption_type, :local_task_data
|
10
|
+
attr_accessor :dev_mode_logins, :dev_mode_options, :dev_mode_mode, :dev_mode_appinstance, :dev_mode_user, :dev_mode_pass, :dev_mode_admin, :dev_mode_secret_access_key,:dev_mode_access_key_id,:aws_region, :s3_bucket_name, :s3_folder_name, :insert_migrations, :skip_connect, :encryption_type, :local_task_data
|
11
11
|
|
12
12
|
def initialize
|
13
13
|
@default_locale = :en
|
@@ -23,7 +23,6 @@ module ZuoraConnect
|
|
23
23
|
@skip_connect = false
|
24
24
|
@encryption_type = :direct
|
25
25
|
@local_task_data = false
|
26
|
-
@disable_provisioning = false
|
27
26
|
|
28
27
|
# Setting the app name for telegraf write
|
29
28
|
@enable_metrics = false
|
@@ -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
|
|
@@ -479,10 +446,6 @@ module ZuoraConnect
|
|
479
446
|
|
480
447
|
#We have no deployed instance for this tenant
|
481
448
|
else
|
482
|
-
if ZuoraConnect.configuration.disable_provisioning
|
483
|
-
raise ZuoraConnect::Exceptions::AccessDenied.new("Provisioning is suspended")
|
484
|
-
end
|
485
|
-
|
486
449
|
#Ensure user can access oauth creation API
|
487
450
|
if !session["ZuoraCurrentUserInfo"]['permissions'].include?("permission.userManagement")
|
488
451
|
Thread.current[:appinstance] = nil
|
@@ -590,40 +553,6 @@ module ZuoraConnect
|
|
590
553
|
session["appInstance"] = @appinstance.id
|
591
554
|
end
|
592
555
|
|
593
|
-
zuora_org_id = cookies['Zuora-Org-Id'] || request.headers['Zuora-Org-Id']
|
594
|
-
zuora_return_nested_orgs_data =
|
595
|
-
cookies['Zuora-Return-Nested-Orgs-Data'].to_bool ||
|
596
|
-
request.headers['Zuora-Return-Nested-Orgs-Data'].to_bool
|
597
|
-
ZuoraConnect::ZuoraUser.current_org_id = zuora_org_id
|
598
|
-
ZuoraConnect::ZuoraUser.current_org_child_org_ids = nil
|
599
|
-
|
600
|
-
if zuora_return_nested_orgs_data
|
601
|
-
cached_session = @appinstance.data_lookup(session: session)
|
602
|
-
|
603
|
-
if cached_session['zuora_org_id'] == ZuoraConnect::ZuoraUser.current_org_id &&
|
604
|
-
cached_session.key?('zuora_org_child_org_ids')
|
605
|
-
ZuoraConnect::ZuoraUser.current_org_child_org_ids = cached_session['zuora_org_child_org_ids']
|
606
|
-
else
|
607
|
-
begin
|
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
|
-
rescue ZuoraAPI::Exceptions::ZuoraAPIError => ex
|
618
|
-
if ex.message.include?('organization does not exist')
|
619
|
-
raise ZuoraConnect::Exceptions::OrganizationAccessForbidden
|
620
|
-
else
|
621
|
-
raise
|
622
|
-
end
|
623
|
-
end
|
624
|
-
ZuoraConnect::ZuoraUser.current_org_child_org_ids = child_org_list.map { |org| org['id'] }
|
625
|
-
end
|
626
|
-
end
|
627
556
|
rescue ZuoraAPI::Exceptions::ZuoraAPIAuthenticationTypeError => ex
|
628
557
|
output_xml, input_xml, response = zuora_client.soap_call(errors: [], z_session: false, zuora_track_id: ZuoraConnect::RequestIdMiddleware.zuora_request_id) do |xml|
|
629
558
|
xml['api'].getUserInfo
|
@@ -640,17 +569,6 @@ module ZuoraConnect
|
|
640
569
|
redirect_to "https://#{zuora_host}/apps/newlogin.do?retURL=#{request.fullpath}&pos=1"
|
641
570
|
return
|
642
571
|
|
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
572
|
rescue ZuoraAPI::Exceptions::ZuoraAPIError, Exception => ex
|
655
573
|
if ex.message.include?("Referenced User resource(s) not found") && ex.class == ZuoraAPI::Exceptions::ZuoraAPIError
|
656
574
|
locals = {title: "Provisioning Error", message: "New tenants need to be provisioned by API Gateway('#{ex.message}'). Please contact support."}
|
@@ -661,15 +579,7 @@ module ZuoraConnect
|
|
661
579
|
zuora_details.merge!({:error => ex.response.body})
|
662
580
|
end
|
663
581
|
ZuoraConnect.logger.error("UI Authorization Error", ex, zuora: zuora_details)
|
664
|
-
|
665
|
-
respond_to do |format|
|
666
|
-
format.html {
|
667
|
-
render "zuora_connect/static/error_unhandled", locals: {exception: ex, skip_exception: true}, layout: false, status: 500
|
668
|
-
}
|
669
|
-
format.js {
|
670
|
-
render "zuora_connect/static/error_unhandled", locals: {exception: ex, skip_exception: true}, layout: false, status: 500
|
671
|
-
}
|
672
|
-
end
|
582
|
+
render "zuora_connect/static/error_unhandled", locals: {exception: ex, skip_exception: true}, layout: false, status: 500
|
673
583
|
end
|
674
584
|
return
|
675
585
|
end
|
@@ -691,10 +601,6 @@ module ZuoraConnect
|
|
691
601
|
@appinstance = ZuoraConnect::AppInstance.find_by(:id => values["appInstance"].to_i)
|
692
602
|
|
693
603
|
if @appinstance.blank?
|
694
|
-
if ZuoraConnect.configuration.disable_provisioning
|
695
|
-
raise ZuoraConnect::Exceptions::AccessDenied.new("Provisioning is suspended")
|
696
|
-
end
|
697
|
-
|
698
604
|
Apartment::Tenant.switch!("public")
|
699
605
|
begin
|
700
606
|
Apartment::Tenant.create(values["appInstance"].to_s)
|
@@ -65,19 +65,5 @@ module ZuoraConnect
|
|
65
65
|
@message || @default_message
|
66
66
|
end
|
67
67
|
end
|
68
|
-
|
69
|
-
|
70
|
-
class OrganizationAccessForbidden < Error
|
71
|
-
attr_writer :default_message
|
72
|
-
|
73
|
-
def initialize(message = nil)
|
74
|
-
@message = message
|
75
|
-
@default_message = "You are not authorized to access with the current organization."
|
76
|
-
end
|
77
|
-
|
78
|
-
def to_s
|
79
|
-
@message || @default_message
|
80
|
-
end
|
81
|
-
end
|
82
68
|
end
|
83
69
|
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: 3.1.5
|
4
|
+
version: 3.1.5
|
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-08-04 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:
|