azure-storage 0.13.0.preview → 0.14.0.preview
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/lib/azure/storage.rb +14 -13
- data/lib/azure/storage/autoload.rb +31 -31
- data/lib/azure/storage/blob/append.rb +43 -41
- data/lib/azure/storage/blob/blob.rb +150 -147
- data/lib/azure/storage/blob/blob_service.rb +186 -184
- data/lib/azure/storage/blob/block.rb +56 -56
- data/lib/azure/storage/blob/container.rb +93 -92
- data/lib/azure/storage/blob/page.rb +187 -104
- data/lib/azure/storage/blob/serialization.rb +32 -18
- data/lib/azure/storage/client.rb +18 -17
- data/lib/azure/storage/client_options.rb +192 -193
- data/lib/azure/storage/client_options_error.rb +5 -5
- data/lib/azure/storage/configurable.rb +39 -39
- data/lib/azure/storage/core.rb +6 -4
- data/lib/azure/storage/core/auth/shared_access_signature.rb +5 -3
- data/lib/azure/storage/core/auth/shared_access_signature_generator.rb +34 -33
- data/lib/azure/storage/core/auth/shared_access_signature_signer.rb +5 -5
- data/lib/azure/storage/core/auth/shared_key.rb +17 -15
- data/lib/azure/storage/core/autoload.rb +15 -13
- data/lib/azure/storage/core/error.rb +3 -1
- data/lib/azure/storage/core/filter/exponential_retry_filter.rb +13 -11
- data/lib/azure/storage/core/filter/linear_retry_filter.rb +10 -8
- data/lib/azure/storage/core/filter/retry_filter.rb +30 -29
- data/lib/azure/storage/core/http_client.rb +18 -16
- data/lib/azure/storage/core/sr.rb +50 -48
- data/lib/azure/storage/core/utility.rb +19 -17
- data/lib/azure/storage/default.rb +371 -361
- data/lib/azure/storage/file/directory.rb +36 -31
- data/lib/azure/storage/file/file.rb +103 -100
- data/lib/azure/storage/file/file_service.rb +42 -40
- data/lib/azure/storage/file/serialization.rb +9 -6
- data/lib/azure/storage/file/share.rb +48 -46
- data/lib/azure/storage/queue/message.rb +3 -1
- data/lib/azure/storage/queue/queue.rb +3 -2
- data/lib/azure/storage/queue/queue_service.rb +152 -151
- data/lib/azure/storage/queue/serialization.rb +7 -5
- data/lib/azure/storage/service/access_policy.rb +3 -1
- data/lib/azure/storage/service/cors.rb +4 -2
- data/lib/azure/storage/service/cors_rule.rb +3 -1
- data/lib/azure/storage/service/enumeration_results.rb +3 -1
- data/lib/azure/storage/service/logging.rb +5 -3
- data/lib/azure/storage/service/metrics.rb +5 -3
- data/lib/azure/storage/service/retention_policy.rb +3 -1
- data/lib/azure/storage/service/serialization.rb +31 -30
- data/lib/azure/storage/service/signed_identifier.rb +5 -4
- data/lib/azure/storage/service/storage_service.rb +33 -32
- data/lib/azure/storage/service/storage_service_properties.rb +6 -4
- data/lib/azure/storage/table/auth/shared_key.rb +9 -8
- data/lib/azure/storage/table/batch.rb +55 -55
- data/lib/azure/storage/table/batch_response.rb +17 -17
- data/lib/azure/storage/table/edmtype.rb +9 -7
- data/lib/azure/storage/table/entity.rb +4 -3
- data/lib/azure/storage/table/guid.rb +3 -1
- data/lib/azure/storage/table/query.rb +17 -19
- data/lib/azure/storage/table/serialization.rb +14 -12
- data/lib/azure/storage/table/table_service.rb +79 -80
- data/lib/azure/storage/version.rb +7 -5
- metadata +2 -2
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
#-------------------------------------------------------------------------
|
2
4
|
# # Copyright (c) Microsoft and contributors. All rights reserved.
|
3
5
|
#
|
@@ -22,13 +24,12 @@
|
|
22
24
|
# THE SOFTWARE.
|
23
25
|
#--------------------------------------------------------------------------
|
24
26
|
|
25
|
-
require
|
27
|
+
require "azure/storage/core"
|
26
28
|
|
27
29
|
module Azure::Storage
|
28
|
-
|
29
30
|
class InvalidConnectionStringError < Core::StorageError
|
30
31
|
def initialize(message = SR::INVALID_CONNECTION_STRING)
|
31
|
-
|
32
|
+
super(message)
|
32
33
|
end
|
33
34
|
end
|
34
35
|
|
@@ -37,5 +38,4 @@ module Azure::Storage
|
|
37
38
|
super(message)
|
38
39
|
end
|
39
40
|
end
|
40
|
-
|
41
|
-
end
|
41
|
+
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
#-------------------------------------------------------------------------
|
2
4
|
# # Copyright (c) Microsoft and contributors. All rights reserved.
|
3
5
|
#
|
@@ -25,7 +27,6 @@
|
|
25
27
|
module Azure::Storage
|
26
28
|
# The Azure::Storage::Configurable module provides basic configuration for Azure storage activities.
|
27
29
|
module Configurable
|
28
|
-
|
29
30
|
# @!attribute [w] storage_access_key
|
30
31
|
# @return [String] Azure Storage access key.
|
31
32
|
# @!attribute storage_account_name
|
@@ -93,7 +94,7 @@ module Azure::Storage
|
|
93
94
|
def reset_config!(options = {})
|
94
95
|
Azure::Storage::Configurable.keys.each do |key|
|
95
96
|
value = if self == Azure::Storage
|
96
|
-
|
97
|
+
Azure::Storage::Default.options[key]
|
97
98
|
else
|
98
99
|
Azure::Storage.send(key)
|
99
100
|
end
|
@@ -105,7 +106,7 @@ module Azure::Storage
|
|
105
106
|
end
|
106
107
|
|
107
108
|
alias setup reset_config!
|
108
|
-
|
109
|
+
|
109
110
|
# Storage queue host
|
110
111
|
# @return [String]
|
111
112
|
def storage_queue_host
|
@@ -123,7 +124,7 @@ module Azure::Storage
|
|
123
124
|
def storage_table_host
|
124
125
|
@storage_table_host || default_host(:table)
|
125
126
|
end
|
126
|
-
|
127
|
+
|
127
128
|
# Storage file host
|
128
129
|
# @return [String]
|
129
130
|
def storage_file_host
|
@@ -132,48 +133,47 @@ module Azure::Storage
|
|
132
133
|
|
133
134
|
private
|
134
135
|
|
135
|
-
|
136
|
-
|
137
|
-
|
136
|
+
def default_host(service)
|
137
|
+
"https://#{storage_account_name}.#{service}.core.windows.net" if storage_account_name
|
138
|
+
end
|
138
139
|
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
140
|
+
def setup_options
|
141
|
+
opts = {}
|
142
|
+
Azure::Storage::Configurable.keys.map do |key|
|
143
|
+
opts[key] = Azure::Storage.send(key) if Azure::Storage.send(key)
|
144
|
+
end
|
145
|
+
opts
|
143
146
|
end
|
144
|
-
opts
|
145
|
-
end
|
146
147
|
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
148
|
+
def account_name_from_endpoint(endpoint)
|
149
|
+
return nil if endpoint.nil?
|
150
|
+
uri = URI::parse endpoint
|
151
|
+
fields = uri.host.split "."
|
152
|
+
fields[0]
|
153
|
+
end
|
153
154
|
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
155
|
+
def determine_account_name
|
156
|
+
if instance_variable_get(:@storage_account_name).nil?
|
157
|
+
hosts = [@storage_blob_host, @storage_table_host, @storage_queue_host, @storage_file_host]
|
158
|
+
account_name = nil;
|
159
|
+
hosts.each do |host|
|
160
|
+
parsed = account_name_from_endpoint host
|
161
|
+
if account_name.nil?
|
162
|
+
account_name = parsed
|
163
|
+
elsif !account_name.nil? && !parsed.nil? && (account_name <=> parsed) != (0)
|
164
|
+
raise InvalidOptionsError, "Ambiguous account name in service hosts."
|
165
|
+
end
|
164
166
|
end
|
167
|
+
raise InvalidOptionsError, "Cannot identify account name." if account_name.nil?
|
168
|
+
@storage_account_name = account_name
|
165
169
|
end
|
166
|
-
raise InvalidOptionsError, "Cannot identify account name." if account_name.nil?
|
167
|
-
@storage_account_name = account_name
|
168
170
|
end
|
169
|
-
end
|
170
171
|
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
172
|
+
def setup_signer_for_service
|
173
|
+
if @storage_sas_token
|
174
|
+
determine_account_name
|
175
|
+
@signer = Azure::Storage::Core::Auth::SharedAccessSignatureSigner.new @storage_account_name, @storage_sas_token
|
176
|
+
end
|
175
177
|
end
|
176
|
-
end
|
177
|
-
|
178
178
|
end
|
179
|
-
end
|
179
|
+
end
|
data/lib/azure/storage/core.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
#-------------------------------------------------------------------------
|
2
4
|
# # Copyright (c) Microsoft and contributors. All rights reserved.
|
3
5
|
#
|
@@ -27,7 +29,7 @@ module Azure
|
|
27
29
|
end
|
28
30
|
end
|
29
31
|
|
30
|
-
require
|
31
|
-
require
|
32
|
-
require
|
33
|
-
require
|
32
|
+
require "azure/storage/core/error"
|
33
|
+
require "azure/storage/default"
|
34
|
+
require "azure/storage/core/sr"
|
35
|
+
require "azure/storage/core/utility"
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
#-------------------------------------------------------------------------
|
2
4
|
# # Copyright (c) Microsoft and contributors. All rights reserved.
|
3
5
|
#
|
@@ -22,7 +24,7 @@
|
|
22
24
|
# THE SOFTWARE.
|
23
25
|
#--------------------------------------------------------------------------
|
24
26
|
|
25
|
-
require
|
26
|
-
require
|
27
|
+
require "azure/storage/core/auth/shared_access_signature_generator"
|
28
|
+
require "azure/storage/core/auth/shared_access_signature_signer"
|
27
29
|
|
28
|
-
include Azure::Storage::Core::Auth
|
30
|
+
include Azure::Storage::Core::Auth
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
#-------------------------------------------------------------------------
|
2
4
|
# # Copyright (c) Microsoft and contributors. All rights reserved.
|
3
5
|
#
|
@@ -22,19 +24,18 @@
|
|
22
24
|
# THE SOFTWARE.
|
23
25
|
#--------------------------------------------------------------------------
|
24
26
|
|
25
|
-
require
|
26
|
-
require
|
27
|
-
require
|
28
|
-
require
|
29
|
-
require
|
27
|
+
require "azure/storage/core"
|
28
|
+
require "azure/storage/client_options_error"
|
29
|
+
require "azure/core/auth/signer"
|
30
|
+
require "time"
|
31
|
+
require "uri"
|
30
32
|
|
31
33
|
# @see https://msdn.microsoft.com/library/azure/dn140255.aspx for more information on construction
|
32
34
|
module Azure::Storage::Core
|
33
35
|
module Auth
|
34
36
|
class SharedAccessSignature
|
35
|
-
|
36
37
|
DEFAULTS = {
|
37
|
-
permissions:
|
38
|
+
permissions: "r",
|
38
39
|
version: Azure::Storage::Default::STG_VERSION
|
39
40
|
}
|
40
41
|
|
@@ -102,7 +103,7 @@ module Azure::Storage::Core
|
|
102
103
|
#
|
103
104
|
# @param account_name [String] The account name. Defaults to the one in the global configuration.
|
104
105
|
# @param access_key [String] The access_key encoded in Base64. Defaults to the one in the global configuration.
|
105
|
-
def initialize(account_name=Azure::Storage.storage_account_name, access_key=Azure::Storage.storage_access_key)
|
106
|
+
def initialize(account_name = Azure::Storage.storage_account_name, access_key = Azure::Storage.storage_access_key)
|
106
107
|
@account_name = account_name
|
107
108
|
@signer = Azure::Core::Auth::Signer.new(access_key)
|
108
109
|
end
|
@@ -122,7 +123,7 @@ module Azure::Storage::Core
|
|
122
123
|
# Combination of 'r', 'a', 'u', 'p' in this order for a queue.
|
123
124
|
# Combination of 'r', 'a', 'u', 'd' in this order for a table.
|
124
125
|
# This option must be omitted if it has been specified in an associated stored access policy.
|
125
|
-
# * +:start+ - String. Optional. UTC Date/Time in ISO8601 format.
|
126
|
+
# * +:start+ - String. Optional. UTC Date/Time in ISO8601 format.
|
126
127
|
# * +:expiry+ - String. Optional. UTC Date/Time in ISO8601 format. Default now + 30 minutes.
|
127
128
|
# * +:identifier+ - String. Optional. Identifier for stored access policy.
|
128
129
|
# * +:protocol+ - String. Optional. Permitted protocols.
|
@@ -140,13 +141,13 @@ module Azure::Storage::Core
|
|
140
141
|
# * +:endpk+ - String. Optional but must accompany endrk. The end partition key of a specified partition key range.
|
141
142
|
# * +:startrk+ - String. Optional. The start row key of a specified row key range.
|
142
143
|
# * +:endrk+ - String. Optional. The end row key of a specified row key range.
|
143
|
-
def generate_service_sas_token(path, options={})
|
144
|
+
def generate_service_sas_token(path, options = {})
|
144
145
|
if options.key?(:service)
|
145
146
|
service_type = SERVICE_TYPE_MAPPING[options[:service].to_sym]
|
146
147
|
options.delete(:service)
|
147
148
|
end
|
148
149
|
|
149
|
-
raise Azure::Storage::InvalidOptionsError,"SAS version cannot be set" if options[:version]
|
150
|
+
raise Azure::Storage::InvalidOptionsError, "SAS version cannot be set" if options[:version]
|
150
151
|
|
151
152
|
options = DEFAULTS.merge(options)
|
152
153
|
valid_mappings = SERVICE_KEY_MAPPINGS
|
@@ -154,7 +155,7 @@ module Azure::Storage::Core
|
|
154
155
|
if options[:resource]
|
155
156
|
options.merge!(resource: options[:resource])
|
156
157
|
else
|
157
|
-
options.merge!(resource:
|
158
|
+
options.merge!(resource: "b")
|
158
159
|
end
|
159
160
|
valid_mappings.merge!(BLOB_KEY_MAPPINGS)
|
160
161
|
elsif service_type == Azure::Storage::ServiceType::TABLE
|
@@ -164,20 +165,20 @@ module Azure::Storage::Core
|
|
164
165
|
if options[:resource]
|
165
166
|
options.merge!(resource: options[:resource])
|
166
167
|
else
|
167
|
-
options.merge!(resource:
|
168
|
+
options.merge!(resource: "f")
|
168
169
|
end
|
169
170
|
valid_mappings.merge!(FILE_KEY_MAPPINGS)
|
170
171
|
end
|
171
172
|
|
172
173
|
invalid_options = options.reject { |k, _| valid_mappings.key?(k) }
|
173
|
-
raise Azure::Storage::InvalidOptionsError,"invalid options #{invalid_options} provided for SAS token generate" if invalid_options.length > 0
|
174
|
+
raise Azure::Storage::InvalidOptionsError, "invalid options #{invalid_options} provided for SAS token generate" if invalid_options.length > 0
|
174
175
|
|
175
176
|
canonicalize_time(options)
|
176
177
|
|
177
178
|
query_hash = Hash[options.map { |k, v| [SERVICE_KEY_MAPPINGS[k], v] }]
|
178
|
-
.reject { |k, v| SERVICE_OPTIONAL_QUERY_PARAMS.include?(k) && v.to_s ==
|
179
|
-
.merge(
|
180
|
-
|
179
|
+
.reject { |k, v| SERVICE_OPTIONAL_QUERY_PARAMS.include?(k) && v.to_s == "" }
|
180
|
+
.merge(sig: @signer.sign(signable_string_for_service(service_type, path, options)))
|
181
|
+
|
181
182
|
URI.encode_www_form(query_hash)
|
182
183
|
end
|
183
184
|
|
@@ -225,28 +226,28 @@ module Azure::Storage::Core
|
|
225
226
|
# * +:service+ - String. Required. Accessible services. Combination of 'b' (blob), 'q' (queue), 't' (table), 'f' (file).
|
226
227
|
# * +:resource+ - String. Required. Accessible resource types. Combination of 's' (service), 'c' (container-level), 'o'(object-level).
|
227
228
|
# * +:permissions+ - String. Required. Permissions. Combination of 'r' (read), 'w' (write), 'd'(delete), 'l'(list), 'a'(add),
|
228
|
-
# 'c'(create), 'u'(update), 'p'(process). Permissions are only valid if they match
|
229
|
+
# 'c'(create), 'u'(update), 'p'(process). Permissions are only valid if they match
|
229
230
|
# the specified signed resource type; otherwise they are ignored.
|
230
231
|
# * +:start+ - String. Optional. UTC Date/Time in ISO8601 format.
|
231
232
|
# * +:expiry+ - String. Optional. UTC Date/Time in ISO8601 format. Default now + 30 minutes.
|
232
233
|
# * +:protocol+ - String. Optional. Permitted protocols.
|
233
|
-
# * +:ip_range+ - String. Optional. An IP address or a range of IP addresses from which to accept requests.
|
234
|
+
# * +:ip_range+ - String. Optional. An IP address or a range of IP addresses from which to accept requests.
|
234
235
|
# When specifying a range, note that the range is inclusive.
|
235
|
-
def generate_account_sas_token(options={})
|
236
|
-
raise Azure::Storage::InvalidOptionsError,"SAS version cannot be set" if options[:version]
|
236
|
+
def generate_account_sas_token(options = {})
|
237
|
+
raise Azure::Storage::InvalidOptionsError, "SAS version cannot be set" if options[:version]
|
237
238
|
|
238
239
|
options = DEFAULTS.merge(options)
|
239
240
|
valid_mappings = ACCOUNT_KEY_MAPPINGS
|
240
241
|
|
241
242
|
invalid_options = options.reject { |k, _| valid_mappings.key?(k) }
|
242
|
-
raise Azure::Storage::InvalidOptionsError,"invalid options #{invalid_options} provided for SAS token generate" if invalid_options.length > 0
|
243
|
+
raise Azure::Storage::InvalidOptionsError, "invalid options #{invalid_options} provided for SAS token generate" if invalid_options.length > 0
|
243
244
|
|
244
245
|
canonicalize_time(options)
|
245
246
|
|
246
247
|
query_hash = Hash[options.map { |k, v| [ACCOUNT_KEY_MAPPINGS[k], v] }]
|
247
|
-
.reject { |k, v| ACCOUNT_OPTIONAL_QUERY_PARAMS.include?(k) && v.to_s ==
|
248
|
-
.merge(
|
249
|
-
|
248
|
+
.reject { |k, v| ACCOUNT_OPTIONAL_QUERY_PARAMS.include?(k) && v.to_s == "" }
|
249
|
+
.merge(sig: @signer.sign(signable_string_for_account(options)))
|
250
|
+
|
250
251
|
URI.encode_www_form(query_hash)
|
251
252
|
end
|
252
253
|
|
@@ -265,7 +266,7 @@ module Azure::Storage::Core
|
|
265
266
|
options[:ip_range],
|
266
267
|
options[:protocol],
|
267
268
|
Azure::Storage::Default::STG_VERSION,
|
268
|
-
|
269
|
+
""
|
269
270
|
].join("\n")
|
270
271
|
end
|
271
272
|
|
@@ -278,7 +279,7 @@ module Azure::Storage::Core
|
|
278
279
|
def canonicalize_time(options)
|
279
280
|
options[:start] = Time.parse(options[:start]).utc.iso8601 if options[:start]
|
280
281
|
options[:expiry] = Time.parse(options[:expiry]).utc.iso8601 if options[:expiry]
|
281
|
-
options[:expiry] ||= (Time.now + 60*30).utc.iso8601
|
282
|
+
options[:expiry] ||= (Time.now + 60 * 30).utc.iso8601
|
282
283
|
end
|
283
284
|
|
284
285
|
# A customised URI reflecting options for the resource signed with Shared Access Signature
|
@@ -291,7 +292,7 @@ module Azure::Storage::Core
|
|
291
292
|
# * +:start+ - String. Optional. UTC Date/Time in ISO8601 format.
|
292
293
|
# * +:expiry+ - String. Optional. UTC Date/Time in ISO8601 format. Default now + 30 minutes.
|
293
294
|
# * +:protocol+ - String. Optional. Permitted protocols.
|
294
|
-
# * +:ip_range+ - String. Optional. An IP address or a range of IP addresses from which to accept requests.
|
295
|
+
# * +:ip_range+ - String. Optional. An IP address or a range of IP addresses from which to accept requests.
|
295
296
|
# When specifying a range, note that the range is inclusive.
|
296
297
|
#
|
297
298
|
# Below options for account SAS only
|
@@ -326,20 +327,20 @@ module Azure::Storage::Core
|
|
326
327
|
# * +:startrk+ - String. Optional. The start row key of a specified row key range.
|
327
328
|
# * +:endrk+ - String. Optional. The end row key of a specified row key range.
|
328
329
|
def signed_uri(uri, use_account_sas, options)
|
329
|
-
CGI::parse(uri.query ||
|
330
|
+
CGI::parse(uri.query || "").inject({}) { |memo, (k, v)| memo[k.to_sym] = v; memo }
|
330
331
|
|
331
|
-
if options[:service] == nil
|
332
|
-
host_splits = uri.host.split(
|
332
|
+
if options[:service] == (nil) && uri.host != (nil)
|
333
|
+
host_splits = uri.host.split(".")
|
333
334
|
options[:service] = host_splits[1].chr if host_splits.length > 1 && host_splits[0] == @account_name
|
334
335
|
end
|
335
336
|
|
336
337
|
sas_params = if use_account_sas
|
337
|
-
|
338
|
+
generate_account_sas_token(options)
|
338
339
|
else
|
339
340
|
generate_service_sas_token(uri.path, options)
|
340
341
|
end
|
341
342
|
|
342
|
-
URI.parse(uri.to_s + (uri.query.nil? ?
|
343
|
+
URI.parse(uri.to_s + (uri.query.nil? ? "?" : "&") + sas_params)
|
343
344
|
end
|
344
345
|
end
|
345
346
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
#-------------------------------------------------------------------------
|
2
4
|
# # Copyright (c) Microsoft and contributors. All rights reserved.
|
3
5
|
#
|
@@ -22,27 +24,25 @@
|
|
22
24
|
# THE SOFTWARE.
|
23
25
|
#--------------------------------------------------------------------------
|
24
26
|
|
25
|
-
require
|
27
|
+
require "azure/core/auth/signer"
|
26
28
|
|
27
29
|
module Azure::Storage::Core
|
28
30
|
module Auth
|
29
31
|
class SharedAccessSignatureSigner < Azure::Core::Auth::Signer
|
30
|
-
|
31
32
|
attr :account_name, :sas_token
|
32
33
|
|
33
34
|
# Public: Initialize the Signer with a SharedAccessSignature
|
34
35
|
#
|
35
36
|
# @param account_name [String] The account name. Defaults to the one in the global configuration.
|
36
37
|
# @param sas_token [String] The sas token to be used for signing
|
37
|
-
def initialize(account_name=Azure::Storage.storage_account_name, sas_token=Azure::Storage.storage_sas_token)
|
38
|
+
def initialize(account_name = Azure::Storage.storage_account_name, sas_token = Azure::Storage.storage_sas_token)
|
38
39
|
@account_name = account_name
|
39
40
|
@sas_token = sas_token
|
40
41
|
end
|
41
42
|
|
42
43
|
def sign_request(req)
|
43
|
-
req.uri = URI.parse(req.uri.to_s + (req.uri.query.nil? ?
|
44
|
+
req.uri = URI.parse(req.uri.to_s + (req.uri.query.nil? ? "?" : "&") + sas_token.sub(/^\?/, "") + "&api-version=" + Azure::Storage::Default::STG_VERSION)
|
44
45
|
end
|
45
|
-
|
46
46
|
end
|
47
47
|
end
|
48
48
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
#-------------------------------------------------------------------------
|
2
4
|
# # Copyright (c) Microsoft and contributors. All rights reserved.
|
3
5
|
#
|
@@ -21,9 +23,9 @@
|
|
21
23
|
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
22
24
|
# THE SOFTWARE.
|
23
25
|
#--------------------------------------------------------------------------
|
24
|
-
require
|
25
|
-
require
|
26
|
-
require
|
26
|
+
require "cgi"
|
27
|
+
require "azure/core/auth/signer"
|
28
|
+
require "azure/core/auth/shared_key"
|
27
29
|
|
28
30
|
module Azure::Storage::Core
|
29
31
|
module Auth
|
@@ -38,21 +40,21 @@ module Azure::Storage::Core
|
|
38
40
|
def signable_string(method, uri, headers)
|
39
41
|
[
|
40
42
|
method.to_s.upcase,
|
41
|
-
headers.fetch(
|
42
|
-
headers.fetch(
|
43
|
-
headers.fetch(
|
44
|
-
headers.fetch(
|
45
|
-
headers.fetch(
|
46
|
-
headers.fetch(
|
47
|
-
headers.fetch(
|
48
|
-
headers.fetch(
|
49
|
-
headers.fetch(
|
50
|
-
headers.fetch(
|
51
|
-
headers.fetch(
|
43
|
+
headers.fetch("Content-Encoding", ""),
|
44
|
+
headers.fetch("Content-Language", ""),
|
45
|
+
headers.fetch("Content-Length", "").sub(/^0+/, ""), # from 2015-02-21, if Content-Length == 0, it won't be signed
|
46
|
+
headers.fetch("Content-MD5", ""),
|
47
|
+
headers.fetch("Content-Type", ""),
|
48
|
+
headers.fetch("Date", ""),
|
49
|
+
headers.fetch("If-Modified-Since", ""),
|
50
|
+
headers.fetch("If-Match", ""),
|
51
|
+
headers.fetch("If-None-Match", ""),
|
52
|
+
headers.fetch("If-Unmodified-Since", ""),
|
53
|
+
headers.fetch("Range", ""),
|
52
54
|
canonicalized_headers(headers),
|
53
55
|
canonicalized_resource(uri)
|
54
56
|
].join("\n")
|
55
57
|
end
|
56
58
|
end
|
57
59
|
end
|
58
|
-
end
|
60
|
+
end
|