zuora_connect 1.3.3 → 1.3.4
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 +15 -10
- data/config/initializers/apartment.rb +1 -1
- data/db/migrate/{20160718151733_create_connect_app_instances.rb → 20100718151733_create_connect_app_instances.rb} +0 -0
- data/db/migrate/{20161024162319_add_tokens_to_app_instance.rb → 20101024162319_add_tokens_to_app_instance.rb} +0 -0
- data/db/migrate/{20161024220705_add_token_to_app_instance.rb → 20101024220705_add_token_to_app_instance.rb} +0 -0
- data/db/migrate/{20170131211919_add_sessions_table.rb → 20110131211919_add_sessions_table.rb} +0 -0
- data/db/migrate/{20170411200303_add_expiration_to_app_instance.rb → 20110411200303_add_expiration_to_app_instance.rb} +0 -0
- data/db/migrate/{20170413191512_add_new_api_token.rb → 20110413191512_add_new_api_token.rb} +0 -0
- data/lib/zuora_connect/controllers/helpers.rb +13 -18
- data/lib/zuora_connect/version.rb +1 -1
- metadata +65 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4d0a1663936301df6937dfd0e3a9d14e9a8adb17
|
4
|
+
data.tar.gz: d1ae128cd651e4b0cd2756b03aa46dcefdc482bb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6696c973f9f62c9cec5216aa0605e9e2d536a8e4b9a27af6a0ac305ec51521109a00a52796ed1e1de2caa883a747d02bca50c8e09db920f742c440d7295417ae
|
7
|
+
data.tar.gz: 790724194a8138d404a2acfbbdfe449fc6a0da277fb5e2c29db404066372abd5fd2514f48325c0b4ea57d392a0591f68198cae584a73c76dc2fc28707d9a5e8f
|
@@ -7,13 +7,6 @@ module ZuoraConnect
|
|
7
7
|
def init
|
8
8
|
@options = Hash.new
|
9
9
|
@logins = Hash.new
|
10
|
-
if ZuoraConnect.configuration.use_s3
|
11
|
-
if ZuoraConnect.configuration.mode == "Development"
|
12
|
-
@s3_client = Aws::S3::Resource.new(region: ZuoraConnect.configuration.aws_region,access_key_id: ZuoraConnect.configuration.dev_mode_access_key_id,secret_access_key: ZuoraConnect.configuration.dev_mode_secret_access_key)
|
13
|
-
else
|
14
|
-
@s3_client = Aws::S3::Resource.new(region: ZuoraConnect.configuration.aws_region)
|
15
|
-
end
|
16
|
-
end
|
17
10
|
@valid = false
|
18
11
|
self.attr_builder("timezone", ZuoraConnect.configuration.default_time_zone)
|
19
12
|
self.attr_builder("locale", ZuoraConnect.configuration.default_locale)
|
@@ -24,6 +17,10 @@ module ZuoraConnect
|
|
24
17
|
Thread.current[:appinstance] = self
|
25
18
|
end
|
26
19
|
|
20
|
+
def data_lookup(session)
|
21
|
+
return session.blank? ? {} : session
|
22
|
+
end
|
23
|
+
|
27
24
|
def new_session(session: {}, username: self.access_token, password: self.refresh_token)
|
28
25
|
@api_version = (username.include?("@") ? "v1" : "v2")
|
29
26
|
@username = username
|
@@ -145,13 +142,21 @@ module ZuoraConnect
|
|
145
142
|
|
146
143
|
def upload_to_s3(local_file,s3_path = nil)
|
147
144
|
s3_path = local_file.split("/").last if s3_path.nil?
|
148
|
-
obj =
|
145
|
+
obj = self.s3_client.bucket(ZuoraConnect.configuration.s3_bucket_name).object("#{ZuoraConnect.configuration.s3_folder_name}/#{self.id.to_s}/#{s3_path}}")
|
149
146
|
obj.upload_file(local_file)
|
150
147
|
end
|
151
148
|
|
152
149
|
def get_s3_file_url(key)
|
153
|
-
signer = Aws::S3::Presigner.new(client:
|
154
|
-
url = signer.presigned_url(:get_object, bucket: ZuoraConnect.configuration.s3_bucket_name, key: "#{ZuoraConnect.configuration.s3_folder_name}/#{key}")
|
150
|
+
signer = Aws::S3::Presigner.new(client: self.s3_client)
|
151
|
+
url = signer.presigned_url(:get_object, bucket: ZuoraConnect.configuration.s3_bucket_name, key: "#{ZuoraConnect.configuration.s3_folder_name}/#{self.id.to_s}/#{key}")
|
152
|
+
end
|
153
|
+
|
154
|
+
def s3_client
|
155
|
+
if ZuoraConnect.configuration.mode == "Development"
|
156
|
+
@s3_client ||= Aws::S3::Resource.new(region: ZuoraConnect.configuration.aws_region,access_key_id: ZuoraConnect.configuration.dev_mode_access_key_id,secret_access_key: ZuoraConnect.configuration.dev_mode_secret_access_key)
|
157
|
+
else
|
158
|
+
@s3_client ||= Aws::S3::Resource.new(region: ZuoraConnect.configuration.aws_region)
|
159
|
+
end
|
155
160
|
end
|
156
161
|
|
157
162
|
def self.decrypt_response(resp)
|
@@ -68,7 +68,7 @@ Apartment.configure do |config|
|
|
68
68
|
# e.g when using a PostgreSQL extension like hstore.
|
69
69
|
# Any schemas added here will be available along with your selected Tenant.
|
70
70
|
#
|
71
|
-
|
71
|
+
config.persistent_schemas = %w{ shared_extensions }
|
72
72
|
|
73
73
|
# <== PostgreSQL only options
|
74
74
|
#
|
File without changes
|
File without changes
|
File without changes
|
data/db/migrate/{20170131211919_add_sessions_table.rb → 20110131211919_add_sessions_table.rb}
RENAMED
File without changes
|
File without changes
|
File without changes
|
@@ -4,19 +4,17 @@ module ZuoraConnect
|
|
4
4
|
module Helpers
|
5
5
|
extend ActiveSupport::Concern
|
6
6
|
|
7
|
-
def instance_data_lookup(appinstance = nil)
|
8
|
-
return session.blank? ? {} : session
|
9
|
-
end
|
10
|
-
|
11
7
|
def authenticate_app_api_request
|
12
8
|
start_time = Time.now
|
13
|
-
if !
|
14
|
-
@appinstance = ZuoraConnect::AppInstance.where(:api_token =>
|
9
|
+
if !request.headers["API-Token"].blank?
|
10
|
+
@appinstance = ZuoraConnect::AppInstance.where(:api_token => request.headers["API-Token"]).first
|
11
|
+
Rails.logger.debug("[#{@appinstance.id}] API REQUEST - API token") if !@appinstance.blank?
|
15
12
|
check_instance
|
16
13
|
else
|
17
14
|
authenticate_or_request_with_http_basic do |username, password|
|
18
15
|
@appinstance = ZuoraConnect::AppInstance.where(:token => password).first
|
19
16
|
@appinstance ||= ZuoraConnect::AppInstance.where(:api_token => password).first
|
17
|
+
Rails.logger.debug("[#{@appinstance.id}] API REQUEST - Basic Auth") if !@appinstance.blank?
|
20
18
|
check_instance
|
21
19
|
end
|
22
20
|
end
|
@@ -34,7 +32,7 @@ module ZuoraConnect
|
|
34
32
|
else
|
35
33
|
setup_instance_via_dev_mode
|
36
34
|
end
|
37
|
-
@appinstance.new_session(:session =>
|
35
|
+
@appinstance.new_session(:session => @appinstance.data_lookup(session))
|
38
36
|
I18n.locale = session["#{@appinstance.id}::user::locale"] ? session["#{@appinstance.id}::user::locale"] : @appinstance.locale
|
39
37
|
Time.zone = session["#{@appinstance.id}::user::timezone"] ? session["#{@appinstance.id}::user::timezone"] : @appinstance.timezone
|
40
38
|
Rails.logger.debug("[#{@appinstance.blank? ? "N/A" : @appinstance.id}] Authenticate App Request Completed In - #{(Time.now - start_time).round(2)}s")
|
@@ -112,17 +110,14 @@ module ZuoraConnect
|
|
112
110
|
session["#{@appinstance.id}::admin"] = ZuoraConnect.configuration.dev_mode_admin
|
113
111
|
end
|
114
112
|
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
return @appinstance.valid
|
124
|
-
else
|
125
|
-
render text: "Access Denied", status: :unauthorized
|
113
|
+
def check_instance
|
114
|
+
if !@appinstance.blank?
|
115
|
+
@appinstance.new_session(:session => @appinstance.data_lookup(session))
|
116
|
+
Thread.current[:appinstance] = @appinstance
|
117
|
+
return @appinstance.valid
|
118
|
+
else
|
119
|
+
render text: "Access Denied", status: :unauthorized
|
120
|
+
end
|
126
121
|
end
|
127
122
|
end
|
128
123
|
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: 1.3.
|
4
|
+
version: 1.3.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Connect Team
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-04-
|
11
|
+
date: 2017-04-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord-session_store
|
@@ -87,13 +87,69 @@ dependencies:
|
|
87
87
|
- - "~>"
|
88
88
|
- !ruby/object:Gem::Version
|
89
89
|
version: '3.0'
|
90
|
-
type: :
|
90
|
+
type: :development
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
94
|
- - "~>"
|
95
95
|
- !ruby/object:Gem::Version
|
96
96
|
version: '3.0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: rspec-rails
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: rspec-expectations
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - ">="
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - ">="
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0'
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: factory_girl
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - ">="
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: '0'
|
132
|
+
type: :development
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - ">="
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: '0'
|
139
|
+
- !ruby/object:Gem::Dependency
|
140
|
+
name: pg
|
141
|
+
requirement: !ruby/object:Gem::Requirement
|
142
|
+
requirements:
|
143
|
+
- - ">="
|
144
|
+
- !ruby/object:Gem::Version
|
145
|
+
version: '0'
|
146
|
+
type: :development
|
147
|
+
prerelease: false
|
148
|
+
version_requirements: !ruby/object:Gem::Requirement
|
149
|
+
requirements:
|
150
|
+
- - ">="
|
151
|
+
- !ruby/object:Gem::Version
|
152
|
+
version: '0'
|
97
153
|
- !ruby/object:Gem::Dependency
|
98
154
|
name: aws-sdk-rails
|
99
155
|
requirement: !ruby/object:Gem::Requirement
|
@@ -155,12 +211,12 @@ files:
|
|
155
211
|
- app/views/zuora_connect/static/session_error.html.erb
|
156
212
|
- config/initializers/apartment.rb
|
157
213
|
- config/routes.rb
|
158
|
-
- db/migrate/
|
159
|
-
- db/migrate/
|
160
|
-
- db/migrate/
|
161
|
-
- db/migrate/
|
162
|
-
- db/migrate/
|
163
|
-
- db/migrate/
|
214
|
+
- db/migrate/20100718151733_create_connect_app_instances.rb
|
215
|
+
- db/migrate/20101024162319_add_tokens_to_app_instance.rb
|
216
|
+
- db/migrate/20101024220705_add_token_to_app_instance.rb
|
217
|
+
- db/migrate/20110131211919_add_sessions_table.rb
|
218
|
+
- db/migrate/20110411200303_add_expiration_to_app_instance.rb
|
219
|
+
- db/migrate/20110413191512_add_new_api_token.rb
|
164
220
|
- lib/tasks/zuora_connect_tasks.rake
|
165
221
|
- lib/zuora_connect.rb
|
166
222
|
- lib/zuora_connect/configuration.rb
|