zuora_connectD 1.7.09
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 +7 -0
- data/MIT-LICENSE +20 -0
- data/Rakefile +38 -0
- data/app/assets/javascripts/zuora_connect/api/v1/app_instance.js +2 -0
- data/app/assets/javascripts/zuora_connect/application.js +13 -0
- data/app/assets/stylesheets/zuora_connect/api/v1/app_instance.css +4 -0
- data/app/assets/stylesheets/zuora_connect/application.css +15 -0
- data/app/controllers/zuora_connect/admin/tenant_controller.rb +11 -0
- data/app/controllers/zuora_connect/api/v1/app_instance_controller.rb +45 -0
- data/app/controllers/zuora_connect/application_controller.rb +8 -0
- data/app/controllers/zuora_connect/static_controller.rb +32 -0
- data/app/helpers/zuora_connect/api/v1/app_instance_helper.rb +4 -0
- data/app/helpers/zuora_connect/application_helper.rb +5 -0
- data/app/models/zuora_connect/app_instance.rb +5 -0
- data/app/models/zuora_connect/app_instance_base.rb +811 -0
- data/app/models/zuora_connect/login.rb +36 -0
- data/app/models/zuora_connect/telegraf.rb +88 -0
- data/app/views/layouts/zuora_connect/application.html.erb +14 -0
- data/app/views/sql/refresh_aggregate_table.txt +84 -0
- data/app/views/zuora_connect/static/invalid_app_instance_error.html.erb +65 -0
- data/app/views/zuora_connect/static/session_error.html.erb +63 -0
- data/config/initializers/apartment.rb +95 -0
- data/config/initializers/object_method_hooks.rb +27 -0
- data/config/initializers/postgresql_adapter.rb +32 -0
- data/config/initializers/prometheus.rb +41 -0
- data/config/initializers/redis.rb +10 -0
- data/config/initializers/resque.rb +6 -0
- data/config/initializers/to_bool.rb +24 -0
- data/config/initializers/unicorn.rb +9 -0
- data/config/routes.rb +13 -0
- data/db/migrate/20100718151733_create_connect_app_instances.rb +9 -0
- data/db/migrate/20101024162319_add_tokens_to_app_instance.rb +6 -0
- data/db/migrate/20101024220705_add_token_to_app_instance.rb +5 -0
- data/db/migrate/20110131211919_add_sessions_table.rb +13 -0
- data/db/migrate/20110411200303_add_expiration_to_app_instance.rb +5 -0
- data/db/migrate/20110413191512_add_new_api_token.rb +5 -0
- data/db/migrate/20110503003602_add_catalog_data_to_app_instance.rb +6 -0
- data/db/migrate/20110503003603_add_catalog_mappings_to_app_instance.rb +5 -0
- data/db/migrate/20110503003604_catalog_default.rb +5 -0
- data/db/migrate/20180301052853_add_catalog_attempted_at.rb +5 -0
- data/lib/metrics/influx/point_value.rb +79 -0
- data/lib/metrics/net.rb +218 -0
- data/lib/middleware/metrics_middleware.rb +110 -0
- data/lib/resque/additions.rb +53 -0
- data/lib/resque/dynamic_queues.rb +142 -0
- data/lib/resque/self_lookup.rb +19 -0
- data/lib/resque/silence_done.rb +71 -0
- data/lib/tasks/zuora_connect_tasks.rake +24 -0
- data/lib/zuora_connectD.rb +41 -0
- data/lib/zuora_connectD/configuration.rb +52 -0
- data/lib/zuora_connectD/controllers/helpers.rb +165 -0
- data/lib/zuora_connectD/engine.rb +30 -0
- data/lib/zuora_connectD/exceptions.rb +67 -0
- data/lib/zuora_connectD/railtie.rb +59 -0
- data/lib/zuora_connectD/version.rb +3 -0
- data/lib/zuora_connectD/views/helpers.rb +9 -0
- data/test/controllers/zuora_connect/api/v1/app_instance_controller_test.rb +13 -0
- data/test/dummy/README.rdoc +28 -0
- data/test/dummy/Rakefile +6 -0
- data/test/dummy/app/assets/javascripts/application.js +13 -0
- data/test/dummy/app/assets/stylesheets/application.css +15 -0
- data/test/dummy/app/controllers/application_controller.rb +5 -0
- data/test/dummy/app/helpers/application_helper.rb +2 -0
- data/test/dummy/app/views/layouts/application.html.erb +14 -0
- data/test/dummy/bin/bundle +3 -0
- data/test/dummy/bin/rails +4 -0
- data/test/dummy/bin/rake +4 -0
- data/test/dummy/bin/setup +29 -0
- data/test/dummy/config.ru +4 -0
- data/test/dummy/config/application.rb +26 -0
- data/test/dummy/config/boot.rb +5 -0
- data/test/dummy/config/database.yml +25 -0
- data/test/dummy/config/environment.rb +5 -0
- data/test/dummy/config/environments/development.rb +41 -0
- data/test/dummy/config/environments/production.rb +79 -0
- data/test/dummy/config/environments/test.rb +42 -0
- data/test/dummy/config/initializers/assets.rb +11 -0
- data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/test/dummy/config/initializers/cookies_serializer.rb +3 -0
- data/test/dummy/config/initializers/filter_parameter_logging.rb +4 -0
- data/test/dummy/config/initializers/inflections.rb +16 -0
- data/test/dummy/config/initializers/mime_types.rb +4 -0
- data/test/dummy/config/initializers/session_store.rb +3 -0
- data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/test/dummy/config/locales/en.yml +23 -0
- data/test/dummy/config/routes.rb +4 -0
- data/test/dummy/config/secrets.yml +22 -0
- data/test/dummy/db/development.sqlite3 +0 -0
- data/test/dummy/db/test.sqlite3 +0 -0
- data/test/dummy/log/development.log +2 -0
- data/test/dummy/log/test.log +0 -0
- data/test/dummy/public/404.html +67 -0
- data/test/dummy/public/422.html +67 -0
- data/test/dummy/public/500.html +66 -0
- data/test/dummy/public/favicon.ico +0 -0
- data/test/fixtures/zuora_connect/app_instances.yml +11 -0
- data/test/integration/navigation_test.rb +8 -0
- data/test/lib/generators/zuora_connect/datatable_generator_test.rb +16 -0
- data/test/models/zuora_connect/app_instance_test.rb +9 -0
- data/test/test_helper.rb +21 -0
- data/test/zuora_connect_test.rb +7 -0
- metadata +416 -0
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
module ZuoraConnect
|
|
2
|
+
class Login
|
|
3
|
+
|
|
4
|
+
def initialize (fields)
|
|
5
|
+
@clients = {}
|
|
6
|
+
if fields["tenant_type"] == "Zuora"
|
|
7
|
+
login_fields = fields.map{|k,v| [k.to_sym, v]}.to_h
|
|
8
|
+
login_type = fields.dig("authentication_type").blank? ? 'Basic' : fields.dig("authentication_type").capitalize
|
|
9
|
+
|
|
10
|
+
@clients["Default"] = "::ZuoraAPI::#{login_type}".constantize.new(login_fields)
|
|
11
|
+
@default_entity = fields["entities"][0]["id"] if fields["entities"].size == 1 if fields["entities"] && fields["entities"].size > 0
|
|
12
|
+
if fields["entities"] && fields["entities"].size > 0
|
|
13
|
+
fields["entities"].each do |entity|
|
|
14
|
+
params = {:entity_id => entity["id"]}.merge(login_fields)
|
|
15
|
+
@clients[entity["id"]] = "::ZuoraAPI::#{login_type}".constantize.new(params)
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
self.attr_builder("available_entities", @clients.keys)
|
|
19
|
+
end
|
|
20
|
+
fields.each do |k,v|
|
|
21
|
+
self.attr_builder(k,v)
|
|
22
|
+
end
|
|
23
|
+
@default_entity ||= "Default"
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def attr_builder(field,val)
|
|
27
|
+
singleton_class.class_eval { attr_accessor "#{field}" }
|
|
28
|
+
send("#{field}=", val)
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
def client(id = @default_entity)
|
|
32
|
+
return id.blank? ? @clients[@default_entity] : @clients[id]
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
end
|
|
36
|
+
end
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
module ZuoraConnect
|
|
2
|
+
class Telegraf
|
|
3
|
+
attr_accessor :host
|
|
4
|
+
|
|
5
|
+
OUTBOUND_METRICS = true
|
|
6
|
+
OUTBOUND_METRICS_NAME = "request-outbound"
|
|
7
|
+
INBOUND_METRICS = true
|
|
8
|
+
INBOUND_METRICS_NAME = "request-inbound"
|
|
9
|
+
|
|
10
|
+
def initialize
|
|
11
|
+
self.connect
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def connect
|
|
15
|
+
Rails.logger.debug(self.format_metric_log('Telegraf','Need new connection')) if ZuoraConnect.configuration.telegraf_debug
|
|
16
|
+
uri = URI.parse(ZuoraConnect.configuration.telegraf_endpoint)
|
|
17
|
+
self.host = UDPSocket.new.tap do |socket|
|
|
18
|
+
socket.connect uri.host, uri.port
|
|
19
|
+
end
|
|
20
|
+
rescue => ex
|
|
21
|
+
self.host = nil
|
|
22
|
+
Rails.logger.warn(self.format_metric_log('Telegraf', 'Failed to connect'))
|
|
23
|
+
Rails.logger.warn(self.format_metric_log('Telegraf', ex.class))
|
|
24
|
+
Rails.logger.warn(self.format_metric_log('Telegraf', ex.message))
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def write(direction: 'Unknown', tags: {}, values: {})
|
|
28
|
+
time = Benchmark.measure do |bench|
|
|
29
|
+
# To avoid writing metrics from rspec tests
|
|
30
|
+
if Rails.env.to_sym != :test
|
|
31
|
+
app_instance = Thread.current[:appinstance].present? ? Thread.current[:appinstance].id : 0
|
|
32
|
+
tags = { app_name: app_name, process_type: process_type, app_instance: app_instance, pod_name: pod_name}.merge(tags)
|
|
33
|
+
|
|
34
|
+
if direction == :inbound
|
|
35
|
+
self.write_udp(series: INBOUND_METRICS_NAME, tags: tags, values: values) if INBOUND_METRICS
|
|
36
|
+
elsif direction == :outbound
|
|
37
|
+
self.write_udp(series: OUTBOUND_METRICS_NAME, tags: tags, values: values) if OUTBOUND_METRICS
|
|
38
|
+
else
|
|
39
|
+
self.write_udp(series: direction, tags: tags, values: values)
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
if ZuoraConnect.configuration.telegraf_debug
|
|
44
|
+
Rails.logger.debug(self.format_metric_log('Telegraf', tags.to_s))
|
|
45
|
+
Rails.logger.debug(self.format_metric_log('Telegraf', values.to_s))
|
|
46
|
+
Rails.logger.debug(self.format_metric_log('Telegraf', "Writing '#{direction.capitalize}': #{time.real.round(5)} ms"))
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
def write_udp(series: '', tags: {}, values: {})
|
|
52
|
+
return if !values.present?
|
|
53
|
+
|
|
54
|
+
self.host.write InfluxDB::PointValue.new({series: series, tags: tags, values: values}).dump
|
|
55
|
+
rescue => ex
|
|
56
|
+
self.connect
|
|
57
|
+
Rails.logger.warn(self.format_metric_log('Telegraf','Failed to write udp'))
|
|
58
|
+
Rails.logger.warn(self.format_metric_log('Telegraf', ex.class))
|
|
59
|
+
Rails.logger.warn(self.format_metric_log('Telegraf', ex.message))
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
def app_name
|
|
63
|
+
return ENV['DEIS_APP'].present? ? ENV['DEIS_APP'] : Rails.application.class.parent_name
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
def pod_name
|
|
67
|
+
return ENV['HOSTNAME'].present? ? ENV['HOSTNAME'] : 'Unknown'
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
# Returns the process type if any
|
|
71
|
+
def process_type
|
|
72
|
+
p_type = 'Unknown'
|
|
73
|
+
if ENV['HOSTNAME'] && ENV['DEIS_APP']
|
|
74
|
+
temp = ENV['HOSTNAME'].split(ENV['DEIS_APP'])[1]
|
|
75
|
+
temp = temp.split(/(-[0-9a-zA-Z]{5})$/)[0] # remove the 5 char hash
|
|
76
|
+
p_type = temp[1, temp.rindex("-")-1]
|
|
77
|
+
end
|
|
78
|
+
return p_type
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
def format_metric_log(message, dump = nil)
|
|
82
|
+
message_color, dump_color = "1;91", "0;1"
|
|
83
|
+
log_entry = " \e[#{message_color}m#{message}\e[0m "
|
|
84
|
+
log_entry << "\e[#{dump_color}m%#{String === dump ? 's' : 'p'}\e[0m" % dump if dump
|
|
85
|
+
log_entry
|
|
86
|
+
end
|
|
87
|
+
end
|
|
88
|
+
end
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html>
|
|
3
|
+
<head>
|
|
4
|
+
<title>Connect</title>
|
|
5
|
+
<%= stylesheet_link_tag "zuora_connectD/application", media: "all" %>
|
|
6
|
+
<%= javascript_include_tag "zuora_connectD/application" %>
|
|
7
|
+
<%= csrf_meta_tags %>
|
|
8
|
+
</head>
|
|
9
|
+
<body>
|
|
10
|
+
|
|
11
|
+
<%= yield %>
|
|
12
|
+
|
|
13
|
+
</body>
|
|
14
|
+
</html>
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
CREATE OR REPLACE FUNCTION "shared_extensions".refresh_aggregate_table(aggregate_table_name text, table_name text, filter text, mode text) RETURNS void AS $$
|
|
2
|
+
DECLARE
|
|
3
|
+
schema RECORD;
|
|
4
|
+
result RECORD;
|
|
5
|
+
sql TEXT := '';
|
|
6
|
+
i INTEGER;
|
|
7
|
+
created boolean := false;
|
|
8
|
+
fields_order character varying;
|
|
9
|
+
index_name varchar;
|
|
10
|
+
index_string varchar;
|
|
11
|
+
index_id varchar;
|
|
12
|
+
BEGIN
|
|
13
|
+
IF mode = 'Table' THEN
|
|
14
|
+
raise notice 'Starting aggregate of % to %', table_name, aggregate_table_name;
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
EXECUTE format('DROP TABLE IF EXISTS "public".%I', aggregate_table_name);
|
|
18
|
+
raise notice 'Filter %', filter;
|
|
19
|
+
|
|
20
|
+
FOR schema IN EXECUTE
|
|
21
|
+
format(
|
|
22
|
+
'SELECT schema_name FROM information_schema.schemata WHERE schema_name ~ ''^[0-9]+$'''
|
|
23
|
+
)
|
|
24
|
+
LOOP
|
|
25
|
+
IF NOT created THEN
|
|
26
|
+
-- Create the aggregate table if we haven't already
|
|
27
|
+
EXECUTE format(
|
|
28
|
+
'CREATE TABLE "public".%I (LIKE %I.%I)',
|
|
29
|
+
aggregate_table_name,
|
|
30
|
+
schema.schema_name, table_name
|
|
31
|
+
);
|
|
32
|
+
-- Add a special `schema_name` column, which we'll populate with the name of the schema
|
|
33
|
+
-- each row originated from
|
|
34
|
+
EXECUTE format(
|
|
35
|
+
'ALTER TABLE "public".%I ADD COLUMN schema_name text', aggregate_table_name
|
|
36
|
+
);
|
|
37
|
+
created := true;
|
|
38
|
+
END IF;
|
|
39
|
+
|
|
40
|
+
-- Finally, we'll select everything from this schema's target table, plus the schema's name,
|
|
41
|
+
-- and insert them into our new aggregate table
|
|
42
|
+
EXECUTE format(
|
|
43
|
+
'SELECT string_agg(column_name, '','') from information_schema.columns where table_name = ''%s'' AND table_schema = ''%s''',
|
|
44
|
+
table_name, schema.schema_name
|
|
45
|
+
) into fields_order;
|
|
46
|
+
|
|
47
|
+
raise notice 'Importing Schema %', schema.schema_name;
|
|
48
|
+
|
|
49
|
+
EXECUTE format(
|
|
50
|
+
'INSERT INTO "public".%I (schema_name, %s) (SELECT ''%s'' AS schema_name, * FROM %I.%I %s )',
|
|
51
|
+
aggregate_table_name,
|
|
52
|
+
fields_order,
|
|
53
|
+
schema.schema_name,
|
|
54
|
+
schema.schema_name, table_name,
|
|
55
|
+
filter
|
|
56
|
+
);
|
|
57
|
+
END LOOP;
|
|
58
|
+
|
|
59
|
+
EXECUTE
|
|
60
|
+
format('CREATE INDEX ON "public".%I (schema_name)', aggregate_table_name);
|
|
61
|
+
EXECUTE
|
|
62
|
+
format('CREATE INDEX ON "public".%I (id)', aggregate_table_name);
|
|
63
|
+
END IF;
|
|
64
|
+
IF mode = 'Index' THEN
|
|
65
|
+
FOR index_string, index_name, index_id IN
|
|
66
|
+
SELECT pg_get_indexdef(idx.oid)||';', idx.relname, idx.oid
|
|
67
|
+
from pg_index ind
|
|
68
|
+
join pg_class idx on idx.oid = ind.indexrelid
|
|
69
|
+
join pg_class tbl on tbl.oid = ind.indrelid
|
|
70
|
+
left join pg_namespace ns on ns.oid = tbl.relnamespace where idx.relname != concat(table_name, '_pkey') and tbl.relname = table_name and ns.nspname = 'public'
|
|
71
|
+
LOOP
|
|
72
|
+
BEGIN
|
|
73
|
+
EXECUTE
|
|
74
|
+
format('DROP INDEX IF EXISTS "public"."%s"', concat(aggregate_table_name, '_', index_id));
|
|
75
|
+
|
|
76
|
+
EXECUTE
|
|
77
|
+
format(replace(replace(index_string, index_name, concat(aggregate_table_name, '_', index_id)), concat(' ', table_name, ' '), concat( ' ', aggregate_table_name, ' ')));
|
|
78
|
+
|
|
79
|
+
RAISE NOTICE 'Creating Indexes %', replace(replace(replace(index_string, index_name, concat(aggregate_table_name, '_', index_id)), concat(' ', table_name, ' '), concat( ' ', aggregate_table_name, ' ')), concat('public.', table_name), concat( 'public.', aggregate_table_name)) ;
|
|
80
|
+
END;
|
|
81
|
+
END LOOP;
|
|
82
|
+
END IF;
|
|
83
|
+
END
|
|
84
|
+
$$ LANGUAGE plpgsql;
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
<html><head>
|
|
2
|
+
<title>We're sorry, but something went wrong (500)</title>
|
|
3
|
+
<meta name="viewport" content="width=device-width,initial-scale=1">
|
|
4
|
+
<style>
|
|
5
|
+
body {
|
|
6
|
+
background-color: #EFEFEF;
|
|
7
|
+
color: #2E2F30;
|
|
8
|
+
text-align: center;
|
|
9
|
+
font-family: arial, sans-serif;
|
|
10
|
+
margin: 0;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
div.dialog {
|
|
14
|
+
width: 95%;
|
|
15
|
+
max-width: 33em;
|
|
16
|
+
margin: 4em auto 0;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
div.dialog > div {
|
|
20
|
+
border: 1px solid #CCC;
|
|
21
|
+
border-right-color: #999;
|
|
22
|
+
border-left-color: #999;
|
|
23
|
+
border-bottom-color: #BBB;
|
|
24
|
+
border-top: #B00100 solid 4px;
|
|
25
|
+
border-top-left-radius: 9px;
|
|
26
|
+
border-top-right-radius: 9px;
|
|
27
|
+
background-color: white;
|
|
28
|
+
padding: 7px 12% 0;
|
|
29
|
+
box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
h1 {
|
|
33
|
+
font-size: 100%;
|
|
34
|
+
color: #730E15;
|
|
35
|
+
line-height: 1.5em;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
div.dialog > p {
|
|
39
|
+
margin: 0 0 1em;
|
|
40
|
+
padding: 1em;
|
|
41
|
+
background-color: #F7F7F7;
|
|
42
|
+
border: 1px solid #CCC;
|
|
43
|
+
border-right-color: #999;
|
|
44
|
+
border-left-color: #999;
|
|
45
|
+
border-bottom-color: #999;
|
|
46
|
+
border-bottom-left-radius: 4px;
|
|
47
|
+
border-bottom-right-radius: 4px;
|
|
48
|
+
border-top-color: #DADADA;
|
|
49
|
+
color: #666;
|
|
50
|
+
box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
|
|
51
|
+
}
|
|
52
|
+
</style>
|
|
53
|
+
</head>
|
|
54
|
+
|
|
55
|
+
<body>
|
|
56
|
+
<!-- This file lives in public/500.html -->
|
|
57
|
+
<div class="dialog">
|
|
58
|
+
<div>
|
|
59
|
+
<h1>We're sorry, but this request could not be verified.</h1>
|
|
60
|
+
</div>
|
|
61
|
+
<p>Please try relaunching this application at connect.zuora.com</p>
|
|
62
|
+
</div>
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
</body></html>
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
<html><head>
|
|
2
|
+
<title>We're sorry, but something went wrong (500)</title>
|
|
3
|
+
<meta name="viewport" content="width=device-width,initial-scale=1">
|
|
4
|
+
<style>
|
|
5
|
+
body {
|
|
6
|
+
background-color: #EFEFEF;
|
|
7
|
+
color: #2E2F30;
|
|
8
|
+
text-align: center;
|
|
9
|
+
font-family: arial, sans-serif;
|
|
10
|
+
margin: 0;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
div.dialog {
|
|
14
|
+
width: 95%;
|
|
15
|
+
max-width: 33em;
|
|
16
|
+
margin: 4em auto 0;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
div.dialog > div {
|
|
20
|
+
border: 1px solid #CCC;
|
|
21
|
+
border-right-color: #999;
|
|
22
|
+
border-left-color: #999;
|
|
23
|
+
border-bottom-color: #BBB;
|
|
24
|
+
border-top: #B00100 solid 4px;
|
|
25
|
+
border-top-left-radius: 9px;
|
|
26
|
+
border-top-right-radius: 9px;
|
|
27
|
+
background-color: white;
|
|
28
|
+
padding: 7px 12% 0;
|
|
29
|
+
box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
h1 {
|
|
33
|
+
font-size: 100%;
|
|
34
|
+
color: #730E15;
|
|
35
|
+
line-height: 1.5em;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
div.dialog > p {
|
|
39
|
+
margin: 0 0 1em;
|
|
40
|
+
padding: 1em;
|
|
41
|
+
background-color: #F7F7F7;
|
|
42
|
+
border: 1px solid #CCC;
|
|
43
|
+
border-right-color: #999;
|
|
44
|
+
border-left-color: #999;
|
|
45
|
+
border-bottom-color: #999;
|
|
46
|
+
border-bottom-left-radius: 4px;
|
|
47
|
+
border-bottom-right-radius: 4px;
|
|
48
|
+
border-top-color: #DADADA;
|
|
49
|
+
color: #666;
|
|
50
|
+
box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
|
|
51
|
+
}
|
|
52
|
+
</style>
|
|
53
|
+
</head>
|
|
54
|
+
|
|
55
|
+
<body>
|
|
56
|
+
<!-- This file lives in public/500.html -->
|
|
57
|
+
<div class="dialog">
|
|
58
|
+
<div>
|
|
59
|
+
<h1>Session is invalid</h1>
|
|
60
|
+
</div>
|
|
61
|
+
<p>Please try relaunching the application from connect.zuora.com</p>
|
|
62
|
+
</div>
|
|
63
|
+
</body></html>
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
# You can have Apartment route to the appropriate Tenant by adding some Rack middleware.
|
|
2
|
+
# Apartment can support many different "Elevators" that can take care of this routing to your data.
|
|
3
|
+
# Require whichever Elevator you're using below or none if you have a custom one.
|
|
4
|
+
#
|
|
5
|
+
# require 'apartment/elevators/generic'
|
|
6
|
+
# require 'apartment/elevators/domain'
|
|
7
|
+
#require 'apartment/elevators/subdomain'
|
|
8
|
+
# require 'apartment/elevators/first_subdomain'
|
|
9
|
+
#
|
|
10
|
+
# Apartment Configuration
|
|
11
|
+
#
|
|
12
|
+
Apartment.configure do |config|
|
|
13
|
+
|
|
14
|
+
# Add any models that you do not want to be multi-tenanted, but remain in the global (public) namespace.
|
|
15
|
+
# A typical example would be a Customer or Tenant model that stores each Tenant's information.
|
|
16
|
+
#
|
|
17
|
+
# config.excluded_models = %w{ Tenant }
|
|
18
|
+
|
|
19
|
+
# In order to migrate all of your Tenants you need to provide a list of Tenant names to Apartment.
|
|
20
|
+
# You can make this dynamic by providing a Proc object to be called on migrations.
|
|
21
|
+
# This object should yield either:
|
|
22
|
+
# - an array of strings representing each Tenant name.
|
|
23
|
+
# - a hash which keys are tenant names, and values custom db config (must contain all key/values required in database.yml)
|
|
24
|
+
#
|
|
25
|
+
# config.tenant_names = lambda{ Customer.pluck(:tenant_name) }
|
|
26
|
+
# config.tenant_names = ['tenant1', 'tenant2']
|
|
27
|
+
# config.tenant_names = {
|
|
28
|
+
# 'tenant1' => {
|
|
29
|
+
# adapter: 'postgresql',
|
|
30
|
+
# host: 'some_server',
|
|
31
|
+
# port: 5555,
|
|
32
|
+
# database: 'postgres' # this is not the name of the tenant's db
|
|
33
|
+
# # but the name of the database to connect to before creating the tenant's db
|
|
34
|
+
# # mandatory in postgresql
|
|
35
|
+
# },
|
|
36
|
+
# 'tenant2' => {
|
|
37
|
+
# adapter: 'postgresql',
|
|
38
|
+
# database: 'postgres' # this is not the name of the tenant's db
|
|
39
|
+
# # but the name of the database to connect to before creating the tenant's db
|
|
40
|
+
# # mandatory in postgresql
|
|
41
|
+
# }
|
|
42
|
+
# }
|
|
43
|
+
# config.tenant_names = lambda do
|
|
44
|
+
# Tenant.all.each_with_object({}) do |tenant, hash|
|
|
45
|
+
# hash[tenant.name] = tenant.db_configuration
|
|
46
|
+
# end
|
|
47
|
+
# end
|
|
48
|
+
#
|
|
49
|
+
config.tenant_names = lambda { ZuoraConnect::AppInstance.pluck :id }
|
|
50
|
+
if defined?(ActiveRecord::SessionStore::Session)
|
|
51
|
+
config.excluded_models = ["ZuoraConnect::AppInstance","ZuoraConnect::AppInstanceBase", "ActiveRecord::SessionStore::Session"]
|
|
52
|
+
else
|
|
53
|
+
config.excluded_models = ["ZuoraConnect::AppInstance","ZuoraConnect::AppInstanceBase"]
|
|
54
|
+
end
|
|
55
|
+
#
|
|
56
|
+
# ==> PostgreSQL only options
|
|
57
|
+
|
|
58
|
+
# Specifies whether to use PostgreSQL schemas or create a new database per Tenant.
|
|
59
|
+
# The default behaviour is true.
|
|
60
|
+
#
|
|
61
|
+
config.use_schemas = true
|
|
62
|
+
|
|
63
|
+
# Apartment can be forced to use raw SQL dumps instead of schema.rb for creating new schemas.
|
|
64
|
+
# Use this when you are using some extra features in PostgreSQL that can't be respresented in
|
|
65
|
+
# schema.rb, like materialized views etc. (only applies with use_schemas set to true).
|
|
66
|
+
# (Note: this option doesn't use db/structure.sql, it creates SQL dump by executing pg_dump)
|
|
67
|
+
#
|
|
68
|
+
# config.use_sql = false
|
|
69
|
+
|
|
70
|
+
# There are cases where you might want some schemas to always be in your search_path
|
|
71
|
+
# e.g when using a PostgreSQL extension like hstore.
|
|
72
|
+
# Any schemas added here will be available along with your selected Tenant.
|
|
73
|
+
#
|
|
74
|
+
config.persistent_schemas = %w{ shared_extensions }
|
|
75
|
+
|
|
76
|
+
# <== PostgreSQL only options
|
|
77
|
+
#
|
|
78
|
+
|
|
79
|
+
# By default, and only when not using PostgreSQL schemas, Apartment will prepend the environment
|
|
80
|
+
# to the tenant name to ensure there is no conflict between your environments.
|
|
81
|
+
# This is mainly for the benefit of your development and test environments.
|
|
82
|
+
# Uncomment the line below if you want to disable this behaviour in production.
|
|
83
|
+
#
|
|
84
|
+
# config.prepend_environment = !Rails.env.production?
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
# Setup a custom Tenant switching middleware. The Proc should return the name of the Tenant that
|
|
88
|
+
# you want to switch to.
|
|
89
|
+
# Rails.application.config.middleware.use 'Apartment::Elevators::Generic', lambda { |request|
|
|
90
|
+
# request.host.split('.').first
|
|
91
|
+
# }
|
|
92
|
+
|
|
93
|
+
# Rails.application.config.middleware.use 'Apartment::Elevators::Domain'
|
|
94
|
+
#Rails.application.config.middleware.use 'Apartment::Elevators::Subdomain'
|
|
95
|
+
# Rails.application.config.middleware.use 'Apartment::Elevators::FirstSubdomain'
|