zuora_connect 3.1.2 → 3.1.5.pre.a
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 +48 -6
- data/config/initializers/redis.rb +19 -0
- data/config/routes.rb +1 -0
- data/lib/tasks/zuora_connect_tasks.rake +12 -9
- data/lib/zuora_connect/configuration.rb +2 -1
- data/lib/zuora_connect/controllers/helpers.rb +8 -0
- 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: 19aedfac159e02a6098ddd1d40b8c05c76ed0198a31fefb059fc1efee21f9680
|
|
4
|
+
data.tar.gz: 1e404cfa4449dca2f20380fb25252178739a694115b7335909dd20f500a4cf72
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: e0b52c5b8639d0ead9c33ea46951eb71f6f543bb01e911ef140fa3c55bab38d3c7cbc3445f38ec5064d91093fc1d39427cc0f7be52e4d27652d82a436a708e04
|
|
7
|
+
data.tar.gz: 0a73154220907b992dcf750a036e654c64989f16e45ecb3d24bb89f894da008516efd0ab7853190852dd2ea22ec3edd2490184194d38d877aad29150a40aa377
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
module ZuoraConnect
|
|
2
2
|
class StaticController < ApplicationController
|
|
3
|
-
before_action :authenticate_connect_app_request, :except => [:health, :initialize_app, :provision, :instance_user]
|
|
4
|
-
before_action :clear_connect_app_session, :only => [:health, :initialize_app, :provision, :instance_user]
|
|
5
|
-
after_action :persist_connect_app_session, :except => [:health, :initialize_app, :provision, :instance_user]
|
|
6
|
-
|
|
7
|
-
skip_before_action :verify_authenticity_token, :only => [:initialize_app, :provision]
|
|
8
|
-
http_basic_authenticate_with name: ENV['PROVISION_USER'], password: ENV['PROVISION_SECRET'], :only => [:provision, :instance_user]
|
|
3
|
+
before_action :authenticate_connect_app_request, :except => [:health, :initialize_app, :provision, :instance_user, :instance_drop]
|
|
4
|
+
before_action :clear_connect_app_session, :only => [:health, :initialize_app, :provision, :instance_user, :instance_drop]
|
|
5
|
+
after_action :persist_connect_app_session, :except => [:health, :initialize_app, :provision, :instance_user, :instance_drop]
|
|
9
6
|
|
|
7
|
+
skip_before_action :verify_authenticity_token, :only => [:initialize_app, :provision, :instance_drop]
|
|
8
|
+
http_basic_authenticate_with name: ENV['PROVISION_USER'], password: ENV['PROVISION_SECRET'], :only => [:provision, :instance_user, :instance_drop]
|
|
10
9
|
|
|
11
10
|
def health
|
|
12
11
|
if params[:error].present?
|
|
@@ -52,6 +51,10 @@ module ZuoraConnect
|
|
|
52
51
|
end
|
|
53
52
|
|
|
54
53
|
def provision
|
|
54
|
+
if ZuoraConnect.configuration.disable_provisioning
|
|
55
|
+
render(json: { status: 403, message: 'Provisioning is suspended until 2022-08-17' }, status: 403) && return
|
|
56
|
+
end
|
|
57
|
+
|
|
55
58
|
create_new_instance
|
|
56
59
|
unless performed?
|
|
57
60
|
render json: {
|
|
@@ -119,6 +122,45 @@ module ZuoraConnect
|
|
|
119
122
|
}, status: 500
|
|
120
123
|
end
|
|
121
124
|
|
|
125
|
+
def instance_drop
|
|
126
|
+
host = request.headers.fetch("HOST", nil)
|
|
127
|
+
if host.present? && ZuoraConnect::AppInstance::INTERNAL_HOSTS.include?(host)
|
|
128
|
+
ZuoraConnect::AppInstance.read_master_db do
|
|
129
|
+
instance_id = params[:id]
|
|
130
|
+
@appinstance = ZuoraConnect::AppInstance.find(instance_id)
|
|
131
|
+
if @appinstance.drop_instance
|
|
132
|
+
ZuoraConnect::AppInstance.destroy(instance_id)
|
|
133
|
+
msg = Apartment::Tenant.drop(instance_id)
|
|
134
|
+
|
|
135
|
+
if msg.error_message.present?
|
|
136
|
+
render json: { "message" => msg.error_message }, status: :bad_request
|
|
137
|
+
else
|
|
138
|
+
render json: {
|
|
139
|
+
status: 200,
|
|
140
|
+
message: 'Success',
|
|
141
|
+
app_instance_id: instance_id
|
|
142
|
+
}, status: 200
|
|
143
|
+
end
|
|
144
|
+
else
|
|
145
|
+
render json: { "message" => @appinstance.drop_message }, status: :bad_request
|
|
146
|
+
end
|
|
147
|
+
end
|
|
148
|
+
else
|
|
149
|
+
render json: { "message" => "Host #{host} is not internal" }, status: :bad_request
|
|
150
|
+
end
|
|
151
|
+
rescue StandardError => e
|
|
152
|
+
message = 'Failed to drop instance'
|
|
153
|
+
if performed?
|
|
154
|
+
Rails.logger.error("#{message}: #{performed?}", e)
|
|
155
|
+
else
|
|
156
|
+
Rails.logger.error(message, e)
|
|
157
|
+
render json: {
|
|
158
|
+
status: 500,
|
|
159
|
+
message: message
|
|
160
|
+
}, status: 500
|
|
161
|
+
end
|
|
162
|
+
end
|
|
163
|
+
|
|
122
164
|
private
|
|
123
165
|
|
|
124
166
|
def clear_connect_app_session
|
|
@@ -18,10 +18,29 @@ class Redis
|
|
|
18
18
|
def self.current=(redis)
|
|
19
19
|
@current = redis
|
|
20
20
|
end
|
|
21
|
+
|
|
22
|
+
def self.subscriber
|
|
23
|
+
@subscriber ||= Redis.new
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def self.subscriber=(redis)
|
|
27
|
+
@subscriber = redis
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def self.publisher
|
|
31
|
+
@publisher ||= Redis.new
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def self.publisher=(redis)
|
|
35
|
+
@publisher = redis
|
|
36
|
+
end
|
|
21
37
|
end
|
|
22
38
|
|
|
23
39
|
if defined?(Redis.current)
|
|
24
40
|
Redis.current = Redis.new(:id => "#{ZuoraObservability::Env.full_process_name(process_name: 'Redis')}", :url => redis_url, :timeout => 6, :reconnect_attempts => 2)
|
|
41
|
+
Redis.subscriber = Redis.new(:id => "#{ZuoraObservability::Env.full_process_name(process_name: 'RedisSubscriber')}", :url => redis_url, :timeout => 6, :reconnect_attempts => 2)
|
|
42
|
+
Redis.publisher = Redis.new(:id => "#{ZuoraObservability::Env.full_process_name(process_name: 'RedisPublisher')}", :url => redis_url, :timeout => 6, :reconnect_attempts => 2)
|
|
43
|
+
|
|
25
44
|
browser_urls['Redis'] = { "url" => redis_url }
|
|
26
45
|
if defined?(Resque.redis)
|
|
27
46
|
if resque_url != redis_url
|
data/config/routes.rb
CHANGED
|
@@ -2,15 +2,18 @@ namespace :db do
|
|
|
2
2
|
desc 'Also create shared_extensions Schema'
|
|
3
3
|
task :extensions => :environment do
|
|
4
4
|
# Create Schema
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
ActiveRecord::Base.connection.execute 'CREATE EXTENSION IF NOT EXISTS "uuid-ossp" SCHEMA shared_extensions;'
|
|
11
|
-
}
|
|
5
|
+
ActiveRecord::Base.connection.execute 'CREATE SCHEMA IF NOT EXISTS shared_extensions;'
|
|
6
|
+
# Enable Hstore
|
|
7
|
+
ActiveRecord::Base.connection.execute 'CREATE EXTENSION IF NOT EXISTS HSTORE SCHEMA shared_extensions;'
|
|
8
|
+
# Enable UUID-OSSP
|
|
9
|
+
ActiveRecord::Base.connection.execute 'CREATE EXTENSION IF NOT EXISTS "uuid-ossp" SCHEMA shared_extensions;'
|
|
12
10
|
end
|
|
13
11
|
end
|
|
14
12
|
|
|
15
|
-
Rake::Task["db:create"].enhance
|
|
16
|
-
Rake::Task["db:
|
|
13
|
+
Rake::Task["db:create"].enhance do
|
|
14
|
+
Rake::Task["db:extensions"].invoke
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
Rake::Task["db:test:purge"].enhance do
|
|
18
|
+
Rake::Task["db:extensions"].invoke
|
|
19
|
+
end
|
|
@@ -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, :disable_provisioning
|
|
11
11
|
|
|
12
12
|
def initialize
|
|
13
13
|
@default_locale = :en
|
|
@@ -23,6 +23,7 @@ module ZuoraConnect
|
|
|
23
23
|
@skip_connect = false
|
|
24
24
|
@encryption_type = :direct
|
|
25
25
|
@local_task_data = false
|
|
26
|
+
@disable_provisioning = false
|
|
26
27
|
|
|
27
28
|
# Setting the app name for telegraf write
|
|
28
29
|
@enable_metrics = false
|
|
@@ -446,6 +446,10 @@ module ZuoraConnect
|
|
|
446
446
|
|
|
447
447
|
#We have no deployed instance for this tenant
|
|
448
448
|
else
|
|
449
|
+
if ZuoraConnect.configuration.disable_provisioning
|
|
450
|
+
raise ZuoraConnect::Exceptions::AccessDenied.new("Provisioning is suspended")
|
|
451
|
+
end
|
|
452
|
+
|
|
449
453
|
#Ensure user can access oauth creation API
|
|
450
454
|
if !session["ZuoraCurrentUserInfo"]['permissions'].include?("permission.userManagement")
|
|
451
455
|
Thread.current[:appinstance] = nil
|
|
@@ -601,6 +605,10 @@ module ZuoraConnect
|
|
|
601
605
|
@appinstance = ZuoraConnect::AppInstance.find_by(:id => values["appInstance"].to_i)
|
|
602
606
|
|
|
603
607
|
if @appinstance.blank?
|
|
608
|
+
if ZuoraConnect.configuration.disable_provisioning
|
|
609
|
+
raise ZuoraConnect::Exceptions::AccessDenied.new("Provisioning is suspended")
|
|
610
|
+
end
|
|
611
|
+
|
|
604
612
|
Apartment::Tenant.switch!("public")
|
|
605
613
|
begin
|
|
606
614
|
Apartment::Tenant.create(values["appInstance"].to_s)
|
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.
|
|
4
|
+
version: 3.1.5.pre.a
|
|
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-10 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: 1.3.1
|
|
458
458
|
requirements: []
|
|
459
459
|
rubygems_version: 3.3.7
|
|
460
460
|
signing_key:
|