zuora_connect 3.0.2.pre.c → 3.0.2.pre.g
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 +2 -1
- data/app/views/zuora_connect/static/error_handled.js.erb +1 -1
- data/app/views/zuora_connect/static/error_unhandled.js.erb +1 -1
- data/lib/middleware/metrics_middleware.rb +14 -33
- data/lib/zuora_connect/controllers/helpers.rb +1 -1
- data/lib/zuora_connect/middleware/hallway.rb +34 -0
- data/lib/zuora_connect/railtie.rb +4 -1
- data/lib/zuora_connect/version.rb +3 -1
- data/lib/zuora_connect.rb +1 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b3cede711b0d2e03b8af4d3b6217efff536d7a1c937622534002a7555982aae1
|
4
|
+
data.tar.gz: 86fb27da334cc101429209aab0a3071209cc8c58286d26ac8d9643402ef0c887
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 964dd0285c9ac0202a6f60d17ce4d0c1a17054fb291ae1ff1aeed31205f4e43c4038a98afe416ce154f4b302084f078130aa2f281b998fd84a66bc755ae576cd
|
7
|
+
data.tar.gz: 79f01e5ecf1a176c5e8960d1646c075054effc585196decc5664dde1daa9fabbdb5ec79659156485099739a4dd336022e2a4f7af8b3263f106e7aad4fa5d6392
|
@@ -397,7 +397,8 @@ module ZuoraConnect
|
|
397
397
|
end
|
398
398
|
end
|
399
399
|
rescue => ex
|
400
|
-
|
400
|
+
refresh_count += 1
|
401
|
+
if self['zuora_logins'].present? && refresh_count < 3
|
401
402
|
ZuoraConnect.logger.warn("REFRESH TASK - Fallback to local encrypted store", ex, self.default_ougai_items)
|
402
403
|
skip_connect = true
|
403
404
|
retry
|
@@ -1 +1 @@
|
|
1
|
-
$('body').html('<%= escape_javascript render(:
|
1
|
+
$('body').html('<%= escape_javascript render(:template=> "zuora_connect/static/error_handled", :formats => [:html], :locals => local_assigns, :layout => false) %>');
|
@@ -1 +1 @@
|
|
1
|
-
$('body').html('<%= escape_javascript render(:
|
1
|
+
$('body').html('<%= escape_javascript render(:template=> "zuora_connect/static/error_unhandled", :formats => [:html], :locals => local_assigns, :layout => false) %>');
|
@@ -46,19 +46,10 @@ module ZuoraConnect
|
|
46
46
|
if !ActionDispatch::Request::HTTP_METHODS.include?(env["REQUEST_METHOD"].upcase)
|
47
47
|
[405, {"Content-Type" => "text/plain"}, ["Method Not Allowed"]]
|
48
48
|
else
|
49
|
-
if
|
50
|
-
|
51
|
-
env['PATH_INFO'] = env['PATH_INFO'].gsub(Thread.current[:isHallway], '')
|
52
|
-
env['REQUEST_URI'] = env['REQUEST_URI'].gsub(Thread.current[:isHallway], '')
|
53
|
-
env['REQUEST_PATH'] = env['REQUEST_PATH'].gsub(Thread.current[:isHallway], '')
|
54
|
-
|
55
|
-
#We need the forwarded host header to identify location of tenant
|
49
|
+
if Thread.current[:isHallway]
|
50
|
+
# We need the forwarded host header to identify location of tenant
|
56
51
|
whitelist = Regexp.new(".*[\.]zuora[\.]com$|^zuora[\.]com$")
|
57
|
-
if whitelist.match(env['HTTP_X_FORWARDED_HOST']).present?
|
58
|
-
@bad_headers.delete('HTTP_X_FORWARDED_HOST')
|
59
|
-
end
|
60
|
-
else
|
61
|
-
Thread.current[:isHallway] = nil
|
52
|
+
@bad_headers.delete('HTTP_X_FORWARDED_HOST') if whitelist.match(env['HTTP_X_FORWARDED_HOST']).present?
|
62
53
|
end
|
63
54
|
|
64
55
|
#Remove bad headers
|
@@ -88,28 +79,18 @@ module ZuoraConnect
|
|
88
79
|
begin
|
89
80
|
@status, @headers, @response = @app.call(env)
|
90
81
|
ensure
|
82
|
+
# Writing to telegraf: Handle 404
|
83
|
+
if [404, 500].include?(@status)
|
84
|
+
content_type = @headers['Content-Type'].split(';')[0] if @headers['Content-Type']
|
85
|
+
content_type = content_type.gsub('text/javascript', 'application/javascript')
|
86
|
+
tags = { status: @status, content_type: content_type }
|
91
87
|
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
request_path = "#{controller_path}#UnknownAction"
|
99
|
-
else
|
100
|
-
# Writing to telegraf: Handle 404
|
101
|
-
if [404, 500].include?(@status)
|
102
|
-
content_type = @headers['Content-Type'].split(';')[0] if @headers['Content-Type']
|
103
|
-
content_type = content_type.gsub('text/javascript', 'application/javascript')
|
104
|
-
tags = {status: @status, content_type: content_type}
|
105
|
-
|
106
|
-
tags = tags.merge({controller: 'ActionController'})
|
107
|
-
tags = tags.merge({action: 'RoutingError' }) if @status == 404
|
108
|
-
|
109
|
-
values = {response_time: ((Time.now - start_time)*1000).round(2) }
|
110
|
-
|
111
|
-
ZuoraConnect::AppInstanceBase.write_to_telegraf(direction: :inbound, tags: tags, values: values)
|
112
|
-
end
|
88
|
+
tags = tags.merge({ controller: 'ActionController' })
|
89
|
+
tags = tags.merge({ action: 'RoutingError' }) if @status == 404
|
90
|
+
|
91
|
+
values = { response_time: ((Time.now - start_time) * 1000).round(2) }
|
92
|
+
|
93
|
+
ZuoraConnect::AppInstanceBase.write_to_telegraf(direction: :inbound, tags: tags, values: values)
|
113
94
|
end
|
114
95
|
Thread.current[:inbound_metric] = nil
|
115
96
|
end
|
@@ -308,7 +308,7 @@ module ZuoraConnect
|
|
308
308
|
if zuora_entity_id.present?
|
309
309
|
zuora_tenant_id = cookies['Zuora-Tenant-Id']
|
310
310
|
zuora_user_id = cookies['Zuora-User-Id']
|
311
|
-
zuora_host = request.headers['HTTP_X_FORWARDED_HOST'] || request.headers['
|
311
|
+
zuora_host = request.headers['HTTP_X_FORWARDED_HOST'] || request.headers['HTTP_ZUORA_HOST'] || 'apisandbox.zuora.com'
|
312
312
|
|
313
313
|
zuora_details = {'host' => zuora_host, 'user_id' => zuora_user_id, 'tenant_id' => zuora_tenant_id, 'entity_id' => zuora_entity_id}
|
314
314
|
auth_headers = {}
|
@@ -0,0 +1,34 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module ZuoraConnect
|
4
|
+
module Middleware
|
5
|
+
# Enables requests to be served from dynamic paths, determined by headers
|
6
|
+
class Hallway
|
7
|
+
UI_PATH = 'HTTP_ZUORA_UI_PATH'
|
8
|
+
LAYOUT_ID = 'HTTP_ZUORA_LAYOUT_FETCH_TEMPLATE_ID'
|
9
|
+
|
10
|
+
def initialize(app)
|
11
|
+
@app = app
|
12
|
+
end
|
13
|
+
|
14
|
+
def call(env)
|
15
|
+
dynamic_path = env[UI_PATH].presence || layout_id(env)
|
16
|
+
|
17
|
+
Thread.current[:isHallway] = dynamic_path
|
18
|
+
|
19
|
+
if dynamic_path.present?
|
20
|
+
env['SCRIPT_NAME'] = dynamic_path
|
21
|
+
env['PATH_INFO'] = env['PATH_INFO'].sub(dynamic_path, '')
|
22
|
+
end
|
23
|
+
|
24
|
+
@app.call(env)
|
25
|
+
end
|
26
|
+
|
27
|
+
private
|
28
|
+
|
29
|
+
def layout_id(env)
|
30
|
+
"/#{env[LAYOUT_ID]}" if env[LAYOUT_ID].present?
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'middleware/metrics_middleware'
|
2
4
|
require 'middleware/request_id_middleware'
|
3
5
|
require 'middleware/json_parse_errors'
|
@@ -17,7 +19,8 @@ module ZuoraConnect
|
|
17
19
|
end
|
18
20
|
|
19
21
|
initializer "zuora_connect.configure_rails_initialization" do |app|
|
20
|
-
app.middleware.insert_after Rack::Sendfile, ZuoraConnect::
|
22
|
+
app.middleware.insert_after Rack::Sendfile, ZuoraConnect::Middleware::Hallway
|
23
|
+
app.middleware.insert_after ZuoraConnect::Middleware::Hallway, ZuoraConnect::MetricsMiddleware
|
21
24
|
app.middleware.insert_after ActionDispatch::RequestId, ZuoraConnect::RequestIdMiddleware
|
22
25
|
app.config.middleware.use ZuoraConnect::JsonParseErrors
|
23
26
|
end
|
data/lib/zuora_connect.rb
CHANGED
@@ -2,6 +2,7 @@ require 'zuora_connect/configuration'
|
|
2
2
|
require "zuora_connect/engine"
|
3
3
|
require 'zuora_connect/exceptions'
|
4
4
|
require 'zuora_connect/controllers/helpers'
|
5
|
+
require 'zuora_connect/middleware/hallway'
|
5
6
|
require 'zuora_connect/railtie'
|
6
7
|
require 'resque/additions'
|
7
8
|
require 'resque/dynamic_queues'
|
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.0.2.pre.
|
4
|
+
version: 3.0.2.pre.g
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Connect Team
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-08-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: apartment
|
@@ -424,6 +424,7 @@ files:
|
|
424
424
|
- lib/zuora_connect/controllers/helpers.rb
|
425
425
|
- lib/zuora_connect/engine.rb
|
426
426
|
- lib/zuora_connect/exceptions.rb
|
427
|
+
- lib/zuora_connect/middleware/hallway.rb
|
427
428
|
- lib/zuora_connect/railtie.rb
|
428
429
|
- lib/zuora_connect/version.rb
|
429
430
|
homepage:
|