zuora_connect 2.0.60c → 2.0.60h
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/models/zuora_connect/app_instance_base.rb +8 -4
- data/config/initializers/postgresql_adapter.rb +34 -1
- data/lib/middleware/json_parse_errors.rb +13 -2
- data/lib/resque/dynamic_queues.rb +1 -1
- data/lib/zuora_connect/controllers/helpers.rb +11 -4
- data/lib/zuora_connect/railtie.rb +15 -0
- data/lib/zuora_connect/version.rb +1 -1
- metadata +27 -27
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f42f8d9aa43845b520355af09e97e78350733a04f0585aeb04fafc7f5ed6a1d6
|
4
|
+
data.tar.gz: 7dfd646a3fa29e7ddbc57ecc461c9d0789a44fecd9eca7a17bdde0e8e037396b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 504efdf52062062981373b857b4ff520473e065a4b9d59f1b4282e4c10de2f06285ba2a80790d810362ad62b011d5ffba7f0fb3235e40fc94b629ea59eff2119
|
7
|
+
data.tar.gz: 210ed53a545c3b86beaf0d7dfa08d567f53b88d0f2d711008bf73b15ebb14b38cdb2c310d4dd9cac891364877856c0b9e9b232bd39838fca5a786f896db6ccbb
|
@@ -338,6 +338,10 @@ module ZuoraConnect
|
|
338
338
|
raise
|
339
339
|
end
|
340
340
|
|
341
|
+
def aws_secrets
|
342
|
+
(Rails.application.secrets.aws || {}).transform_keys { |key| key.to_s }
|
343
|
+
end
|
344
|
+
|
341
345
|
#### START KMS ENCRYPTION Methods ####
|
342
346
|
def zuora_logins=(val)
|
343
347
|
write_attribute(:zuora_logins, kms_encrypt(val.to_json))
|
@@ -350,7 +354,7 @@ module ZuoraConnect
|
|
350
354
|
|
351
355
|
def kms_decrypt(value)
|
352
356
|
kms_tries ||= 0
|
353
|
-
kms_client = Aws::KMS::Client.new({region:
|
357
|
+
kms_client = Aws::KMS::Client.new({region: aws_secrets['AWS_REGION'], credentials: self.aws_auth_client}.delete_if { |k, v| v.blank? })
|
354
358
|
resp = kms_client.decrypt({ciphertext_blob: [value].pack("H*") })
|
355
359
|
return resp.plaintext
|
356
360
|
rescue *AWS_AUTH_ERRORS => ex
|
@@ -365,7 +369,7 @@ module ZuoraConnect
|
|
365
369
|
|
366
370
|
def kms_encrypt(value)
|
367
371
|
kms_tries ||= 0
|
368
|
-
kms_client = Aws::KMS::Client.new({region:
|
372
|
+
kms_client = Aws::KMS::Client.new({region: aws_secrets['AWS_REGION'], credentials: self.aws_auth_client}.delete_if {|k,v| v.blank? })
|
369
373
|
|
370
374
|
resp = kms_client.encrypt({key_id: kms_key, plaintext: value})
|
371
375
|
return resp.ciphertext_blob.unpack('H*').first
|
@@ -380,12 +384,12 @@ module ZuoraConnect
|
|
380
384
|
end
|
381
385
|
|
382
386
|
def kms_key
|
383
|
-
return ENV['AWS_KMS_ARN'] ||
|
387
|
+
return ENV['AWS_KMS_ARN'] || aws_secrets['AWS_KMS_ARN']
|
384
388
|
end
|
385
389
|
|
386
390
|
def aws_auth_client
|
387
391
|
if Rails.env.to_s == 'development'
|
388
|
-
return Aws::Credentials.new(
|
392
|
+
return Aws::Credentials.new(aws_secrets['AWS_ACCESS_KEY_ID'], aws_secrets['AWS_SECRET_ACCESS_KEY'])
|
389
393
|
else
|
390
394
|
return nil
|
391
395
|
end
|
@@ -2,7 +2,33 @@ module ActiveRecord
|
|
2
2
|
module ConnectionAdapters
|
3
3
|
class PostgreSQLAdapter < AbstractAdapter
|
4
4
|
private
|
5
|
-
def
|
5
|
+
def load_additional_types_latest(oids = nil)
|
6
|
+
initializer = OID::TypeMapInitializer.new(type_map)
|
7
|
+
if supports_ranges?
|
8
|
+
query = <<-SQL
|
9
|
+
SELECT DISTINCT on (t.typname) t.oid, t.typname, t.typelem, t.typdelim, t.typinput, r.rngsubtype, t.typtype, t.typbasetype
|
10
|
+
FROM pg_type as t
|
11
|
+
LEFT JOIN pg_range as r ON oid = rngtypid
|
12
|
+
SQL
|
13
|
+
else
|
14
|
+
query = <<-SQL
|
15
|
+
SELECT DISTINCT on (t.typname) t.oid, t.typname, t.typelem, t.typdelim, t.typinput, t.typtype, t.typbasetype
|
16
|
+
FROM pg_type as t
|
17
|
+
SQL
|
18
|
+
end
|
19
|
+
|
20
|
+
if oids
|
21
|
+
query += "WHERE t.oid::integer IN (%s)" % oids.join(", ")
|
22
|
+
else
|
23
|
+
query += initializer.query_conditions_for_initial_load
|
24
|
+
end
|
25
|
+
|
26
|
+
execute_and_clear(query, "SCHEMA", []) do |records|
|
27
|
+
initializer.run(records)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
def load_additional_types_deprecated(type_map, oids = nil)
|
6
32
|
initializer = OID::TypeMapInitializer.new(type_map)
|
7
33
|
if supports_ranges?
|
8
34
|
query = <<-SQL
|
@@ -27,6 +53,13 @@ module ActiveRecord
|
|
27
53
|
initializer.run(records)
|
28
54
|
end
|
29
55
|
end
|
56
|
+
|
57
|
+
rails_version = Rails.version.split('.').map { |x| x.to_i }
|
58
|
+
if (rails_version <=> [5, 2, 0]) >= 1
|
59
|
+
alias :load_additional_types :load_additional_types_latest
|
60
|
+
else
|
61
|
+
alias :load_additional_types :load_additional_types_deprecated
|
62
|
+
end
|
30
63
|
end
|
31
64
|
end
|
32
65
|
end
|
@@ -7,7 +7,7 @@ module ZuoraConnect
|
|
7
7
|
def call(env)
|
8
8
|
begin
|
9
9
|
@app.call(env)
|
10
|
-
rescue
|
10
|
+
rescue DynamicRailsError => error
|
11
11
|
if env['HTTP_ACCEPT'] =~ /application\/json/ || env['CONTENT_TYPE'] =~ /application\/json/
|
12
12
|
return [
|
13
13
|
400, { "Content-Type" => "application/json" },
|
@@ -18,5 +18,16 @@ module ZuoraConnect
|
|
18
18
|
end
|
19
19
|
end
|
20
20
|
end
|
21
|
+
|
22
|
+
# Note(hartley): remove once the minimum supported version of Rails is 5.2
|
23
|
+
class DynamicRailsError < StandardError
|
24
|
+
def self.===(exception)
|
25
|
+
if Rails.version >= "5.2"
|
26
|
+
exception.is_a?(ActionDispatch::Http::Parameters::ParseError)
|
27
|
+
else
|
28
|
+
exception.is_a?(ActionDispatch::ParamsParser::ParseError)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
21
32
|
end
|
22
|
-
end
|
33
|
+
end
|
@@ -124,10 +124,15 @@ module ZuoraConnect
|
|
124
124
|
ElasticAPM.set_user(session["#{@appinstance.id}::user::email"]) if defined?(ElasticAPM) && ElasticAPM.running?
|
125
125
|
PaperTrail.whodunnit = session["#{@appinstance.id}::user::email"] if defined?(PaperTrail)
|
126
126
|
end
|
127
|
+
|
128
|
+
locale = (session["#{@appinstance.id}::user::locale"] || "").gsub("_", "-")
|
127
129
|
begin
|
128
|
-
locale = session["#{@appinstance.id}::user::locale"]
|
129
130
|
I18n.locale = locale.present? ? locale : @appinstance.locale
|
130
131
|
rescue I18n::InvalidLocale => ex
|
132
|
+
if locale.include?("-")
|
133
|
+
locale = locale.split("-").first
|
134
|
+
retry
|
135
|
+
end
|
131
136
|
ZuoraConnect.logger.error(ex) if !ZuoraConnect::AppInstance::IGNORED_LOCALS.include?(ex.locale.to_s.downcase)
|
132
137
|
end
|
133
138
|
begin
|
@@ -411,6 +416,7 @@ module ZuoraConnect
|
|
411
416
|
if defined?(@appinstance) && !@appinstance['zuora_logins'].nil?
|
412
417
|
#Add user/update
|
413
418
|
begin
|
419
|
+
ZuoraConnect::ZuoraUser.reset_table_name
|
414
420
|
@zuora_user = ZuoraConnect::ZuoraUser.where(:zuora_user_id => zuora_user_id).first
|
415
421
|
rescue ActiveRecord::StatementInvalid => ex
|
416
422
|
if ex.message.include?("PG::UndefinedTable") && ex.message.include?("zuora_users")
|
@@ -434,7 +440,8 @@ module ZuoraConnect
|
|
434
440
|
session["#{@appinstance.id}::user::localUserId"] = @zuora_user.id
|
435
441
|
session["#{@appinstance.id}::user::email"] = session['ZuoraCurrentIdentity']["username"]
|
436
442
|
session["#{@appinstance.id}::user::timezone"] = session['ZuoraCurrentIdentity']["timeZone"]
|
437
|
-
session["#{@appinstance.id}::user::
|
443
|
+
session["#{@appinstance.id}::user::language"] = session['ZuoraCurrentIdentity']["language"]
|
444
|
+
session["#{@appinstance.id}::user::locale"] = session['ZuoraCurrentIdentity']["locale"]
|
438
445
|
session["appInstance"] = @appinstance.id
|
439
446
|
|
440
447
|
#We have multiple, user must pick
|
@@ -565,8 +572,8 @@ module ZuoraConnect
|
|
565
572
|
|
566
573
|
rescue ZuoraAPI::Exceptions::ZuoraAPIError, Exception => ex
|
567
574
|
if ex.message.include?("Referenced User resource(s) not found") && ex.class == ZuoraAPI::Exceptions::ZuoraAPIError
|
568
|
-
locals = {title: "Provisioning Error", message: "New
|
569
|
-
render "zuora_connect/static/error_handled", locals: locals, status:
|
575
|
+
locals = {title: "Provisioning Error", message: "New tenants need to be provisioned by API Gateway('#{ex.message}'). Please contact support."}
|
576
|
+
render "zuora_connect/static/error_handled", locals: locals, status: 200, layout: false
|
570
577
|
else
|
571
578
|
session.clear
|
572
579
|
if defined?(ex.response) && ex.response.present? && defined?(ex.response.body)
|
@@ -81,6 +81,21 @@ module ZuoraConnect
|
|
81
81
|
request_headers =
|
82
82
|
event.payload[:headers].env.
|
83
83
|
reject { |key| key.to_s.include?('.') || REQUEST_HEADERS_TO_IGNORE.include?(key.to_s) }
|
84
|
+
begin
|
85
|
+
if request_headers["HTTP_AUTHORIZATION"].present?
|
86
|
+
if request_headers["HTTP_AUTHORIZATION"].include?("Basic")
|
87
|
+
user_password = request_headers["HTTP_AUTHORIZATION"].split("Basic").last.strip
|
88
|
+
user, password = Base64.decode64(user_password).split(":")
|
89
|
+
request_headers["HTTP_AUTHORIZATION"] = "Basic #{user}:ValueFiltered"
|
90
|
+
elsif
|
91
|
+
request_headers["HTTP_AUTHORIZATION"] = "ValueFiltered"
|
92
|
+
end
|
93
|
+
end
|
94
|
+
request_headers["HTTP_API_TOKEN"] = "ValueFiltered" if request_headers["HTTP_API_TOKEN"].present?
|
95
|
+
rescue
|
96
|
+
request_headers.delete("HTTP_API_TOKEN")
|
97
|
+
request_headers.delete("HTTP_AUTHORIZATION")
|
98
|
+
end
|
84
99
|
items.merge!({ headers: request_headers.to_s })
|
85
100
|
end
|
86
101
|
|
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.60h
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Connect Team
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-10-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: apartment
|
@@ -438,44 +438,44 @@ signing_key:
|
|
438
438
|
specification_version: 4
|
439
439
|
summary: Summary of Connect.
|
440
440
|
test_files:
|
441
|
-
- test/integration/navigation_test.rb
|
442
|
-
- test/controllers/zuora_connect/api/v1/app_instance_controller_test.rb
|
443
441
|
- test/fixtures/zuora_connect/app_instances.yml
|
444
|
-
- test/lib/generators/zuora_connect/datatable_generator_test.rb
|
445
442
|
- test/models/zuora_connect/app_instance_test.rb
|
443
|
+
- test/integration/navigation_test.rb
|
444
|
+
- test/controllers/zuora_connect/api/v1/app_instance_controller_test.rb
|
446
445
|
- test/zuora_connect_test.rb
|
447
|
-
- test/
|
448
|
-
- test/dummy/config.ru
|
449
|
-
- test/dummy/public/422.html
|
450
|
-
- test/dummy/public/404.html
|
446
|
+
- test/lib/generators/zuora_connect/datatable_generator_test.rb
|
451
447
|
- test/dummy/public/500.html
|
448
|
+
- test/dummy/public/404.html
|
452
449
|
- test/dummy/public/favicon.ico
|
453
|
-
- test/dummy/
|
454
|
-
- test/dummy/
|
455
|
-
- test/dummy/
|
456
|
-
- test/dummy/app/assets/javascripts/application.js
|
457
|
-
- test/dummy/app/assets/stylesheets/application.css
|
458
|
-
- test/dummy/README.rdoc
|
459
|
-
- test/dummy/bin/rails
|
460
|
-
- test/dummy/bin/rake
|
461
|
-
- test/dummy/bin/bundle
|
462
|
-
- test/dummy/bin/setup
|
450
|
+
- test/dummy/public/422.html
|
451
|
+
- test/dummy/Rakefile
|
452
|
+
- test/dummy/config.ru
|
463
453
|
- test/dummy/config/secrets.yml
|
464
454
|
- test/dummy/config/boot.rb
|
465
|
-
- test/dummy/config/
|
466
|
-
- test/dummy/config/initializers/filter_parameter_logging.rb
|
455
|
+
- test/dummy/config/application.rb
|
467
456
|
- test/dummy/config/initializers/session_store.rb
|
468
|
-
- test/dummy/config/initializers/inflections.rb
|
469
|
-
- test/dummy/config/initializers/cookies_serializer.rb
|
470
457
|
- test/dummy/config/initializers/assets.rb
|
471
458
|
- test/dummy/config/initializers/wrap_parameters.rb
|
459
|
+
- test/dummy/config/initializers/filter_parameter_logging.rb
|
472
460
|
- test/dummy/config/initializers/backtrace_silencers.rb
|
473
|
-
- test/dummy/config/
|
474
|
-
- test/dummy/config/
|
475
|
-
- test/dummy/config/
|
461
|
+
- test/dummy/config/initializers/mime_types.rb
|
462
|
+
- test/dummy/config/initializers/inflections.rb
|
463
|
+
- test/dummy/config/initializers/cookies_serializer.rb
|
476
464
|
- test/dummy/config/routes.rb
|
465
|
+
- test/dummy/config/database.yml
|
466
|
+
- test/dummy/config/environments/test.rb
|
477
467
|
- test/dummy/config/environments/production.rb
|
478
468
|
- test/dummy/config/environments/development.rb
|
479
|
-
- test/dummy/config/
|
469
|
+
- test/dummy/config/environment.rb
|
480
470
|
- test/dummy/config/locales/en.yml
|
471
|
+
- test/dummy/README.rdoc
|
472
|
+
- test/dummy/bin/rake
|
473
|
+
- test/dummy/bin/setup
|
474
|
+
- test/dummy/bin/rails
|
475
|
+
- test/dummy/bin/bundle
|
476
|
+
- test/dummy/app/views/layouts/application.html.erb
|
477
|
+
- test/dummy/app/assets/javascripts/application.js
|
478
|
+
- test/dummy/app/assets/stylesheets/application.css
|
479
|
+
- test/dummy/app/helpers/application_helper.rb
|
480
|
+
- test/dummy/app/controllers/application_controller.rb
|
481
481
|
- test/test_helper.rb
|