azure-storage-common 1.0.1 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 418e60c16c692153cda5d8d21039e1107cfe4f79
4
- data.tar.gz: a4a277709da3afd50f6de5160d7a4840829a51e4
3
+ metadata.gz: 1d3118c38760c68874586862f6d0ff3144f140d2
4
+ data.tar.gz: 86c0b9fa3ac4e07c761985354daa89b7b36fb5aa
5
5
  SHA512:
6
- metadata.gz: d666a2c7c2bbf4968832ccc45016e1a01e8ef23bb3d02d0ff0eb065788047516b11f7d737b94c5a60254b8f7ee60d226a5c00016cb6e33d1ab193de76fb98e89
7
- data.tar.gz: e6fce018e142c87ee59370e4a773ba03d835906e8b49e43f39541968c0b59fd894e2fbb58d42bf7679e16a2ae68637d19817e38b5599161d0c3fbdd267e56612
6
+ metadata.gz: b785d7399791a4d2e2f7a1b673064ebdf1382038f58d7b90ef01a0a5117322e7335801cd04bccbe4c25ad9856dda825a7edf0b75eb0c95301be325aab8b35c4d
7
+ data.tar.gz: 3f4105bb14a56a1c16c6e285215ea1a2604357ea6df7bd5d423d398ef6b3206dbee7185445a7dcff2449ec5482f8258008248bffed27440aff71264ac6dd9959
@@ -103,6 +103,9 @@ module Azure::Storage::Common
103
103
  # * +:default_endpoints_protocol+ - String. http or https
104
104
  # * +:use_path_style_uri+ - String. Whether use path style URI for specified endpoints
105
105
  # * +:ca_file+ - String. File path of the CA file if having issue with SSL
106
+ # * +:ssl_version+ - Symbol. The ssl version to be used, sample: :TLSv1_1, :TLSv1_2, for the details, see https://github.com/ruby/openssl/blob/master/lib/openssl/ssl.rb
107
+ # * +:ssl_min_version+ - Symbol. The min ssl version supported, only supported in Ruby 2.5+
108
+ # * +:ssl_max_version+ - Symbol. The max ssl version supported, only supported in Ruby 2.5+
106
109
  # * +:user_agent_prefix+ - String. The user agent prefix that can identify the application calls the library
107
110
  #
108
111
  # The valid set of options include:
@@ -30,7 +30,7 @@ require "azure/storage/common/core/auth/anonymous_signer"
30
30
 
31
31
  module Azure::Storage::Common
32
32
  module ClientOptions
33
- attr_accessor :ca_file
33
+ attr_accessor :ca_file, :ssl_version, :ssl_min_version, :ssl_max_version
34
34
 
35
35
  # Public: Reset options for [Azure::Storage::Common::Client]
36
36
  #
@@ -55,6 +55,9 @@ module Azure::Storage::Common
55
55
  # * +:default_endpoints_protocol+ - String. http or https
56
56
  # * +:use_path_style_uri+ - String. Whether use path style URI for specified endpoints
57
57
  # * +:ca_file+ - String. File path of the CA file if having issue with SSL
58
+ # * +:ssl_version+ - Symbol. The ssl version to be used, sample: :TLSv1_1, :TLSv1_2, for the details, see https://github.com/ruby/openssl/blob/master/lib/openssl/ssl.rb
59
+ # * +:ssl_min_version+ - Symbol. The min ssl version supported, only supported in Ruby 2.5+
60
+ # * +:ssl_max_version+ - Symbol. The max ssl version supported, only supported in Ruby 2.5+
58
61
  #
59
62
  # The valid set of options include:
60
63
  # * Storage Emulator: +:use_development_storage+ required, +:development_storage_proxy_uri+ optionally
@@ -85,6 +88,9 @@ module Azure::Storage::Common
85
88
  options = load_env if options.length == 0
86
89
 
87
90
  @ca_file = options.delete(:ca_file)
91
+ @ssl_version = options.delete(:ssl_version)
92
+ @ssl_min_version = options.delete(:ssl_min_version)
93
+ @ssl_max_version = options.delete(:ssl_max_version)
88
94
  @options = filter(options)
89
95
  self.send(:reset_config!, @options) if self.respond_to?(:reset_config!)
90
96
  self
@@ -203,7 +209,7 @@ module Azure::Storage::Common
203
209
  begin
204
210
  results = validated_options(opts,
205
211
  required: [:storage_account_name],
206
- only_one: [:storage_access_key, :storage_sas_token],
212
+ only_one: [:storage_access_key, :storage_sas_token, :signer],
207
213
  optional: [:default_endpoints_protocol, :storage_dns_suffix])
208
214
  protocol = results[:default_endpoints_protocol] ||= StorageServiceClientConstants::DEFAULT_PROTOCOL
209
215
  suffix = results[:storage_dns_suffix] ||= StorageServiceClientConstants::DEFAULT_ENDPOINT_SUFFIX
@@ -312,7 +318,8 @@ module Azure::Storage::Common
312
318
  storage_file_host: is_url,
313
319
  storage_dns_suffix: is_url,
314
320
  default_endpoints_protocol: lambda { |i| ["http", "https"].include? i.downcase },
315
- use_path_style_uri: is_true
321
+ use_path_style_uri: is_true,
322
+ signer: lambda { |i| i.is_a? Azure::Core::Auth::Signer}
316
323
  }
317
324
 
318
325
  valid_options = required + at_least_one + only_one + optional
@@ -0,0 +1,43 @@
1
+ # frozen_string_literal: true
2
+
3
+ #-------------------------------------------------------------------------
4
+ # # Copyright (c) Microsoft and contributors. All rights reserved.
5
+ #
6
+ # The MIT License(MIT)
7
+
8
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
9
+ # of this software and associated documentation files(the "Software"), to deal
10
+ # in the Software without restriction, including without limitation the rights
11
+ # to use, copy, modify, merge, publish, distribute, sublicense, and / or sell
12
+ # copies of the Software, and to permit persons to whom the Software is
13
+ # furnished to do so, subject to the following conditions :
14
+
15
+ # The above copyright notice and this permission notice shall be included in
16
+ # all copies or substantial portions of the Software.
17
+
18
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE
21
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24
+ # THE SOFTWARE.
25
+ #--------------------------------------------------------------------------
26
+
27
+ module Azure::Storage::Common::Core
28
+ module Auth
29
+ class TokenSigner < Azure::Core::Auth::Signer
30
+ # Public: Initialize the Token Signer
31
+ def initialize(token_credential)
32
+ @credential = token_credential
33
+ # Use mock key to initialize super class
34
+ super(Base64.strict_encode64("accesstoken"))
35
+ end
36
+
37
+ def sign_request(req)
38
+ req.headers['Authorization'] = "Bearer #{@credential.token}"
39
+ req
40
+ end
41
+ end
42
+ end
43
+ end
@@ -32,11 +32,14 @@ module Azure
32
32
  autoload :Utility, "azure/storage/common/core/utility"
33
33
  autoload :Logger, "azure/storage/common/core/utility"
34
34
  autoload :Error, "azure/storage/common/core/error"
35
+ autoload :TokenCredential, "azure/storage/common/core/token_credential.rb"
35
36
 
36
37
  module Auth
37
38
  autoload :SharedKey, "azure/storage/common/core/auth/shared_key.rb"
38
39
  autoload :SharedAccessSignature, "azure/storage/common/core/auth/shared_access_signature_generator.rb"
39
40
  autoload :SharedAccessSignatureSigner, "azure/storage/common/core/auth/shared_access_signature_signer.rb"
41
+ autoload :AnonymousSigner, "azure/storage/common/core/auth/anonymous_signer.rb"
42
+ autoload :TokenSigner, "azure/storage/common/core/auth/token_signer.rb"
40
43
  end
41
44
 
42
45
  module Filter
@@ -149,7 +149,7 @@ module Azure::Storage::Common::Core::Filter
149
149
 
150
150
  # Adjust the retry parameter and wait for retry
151
151
  def wait_for_retry
152
- sleep @retry_interval
152
+ sleep @retry_interval if @retry_interval > 0
153
153
  end
154
154
 
155
155
  # Adjust the retry request
@@ -184,7 +184,8 @@ module Azure::Storage::Common::Core::Filter
184
184
  0
185
185
  else
186
186
  since_last_attempt = Time.now - lastAttemptTime
187
- retry_data[:interval] - since_last_attempt
187
+ remainder = retry_data[:interval] - since_last_attempt
188
+ remainder > 0 ? remainder : 0
188
189
  end
189
190
  end
190
191
 
@@ -212,7 +213,9 @@ module Azure::Storage::Common::Core::Filter
212
213
  # If a request sent to the secondary location fails with 404 (Not Found), it is possible
213
214
  # that the resource replication is not finished yet. So, in case of 404 only in the secondary
214
215
  # location, the failure should still be retryable.
215
- retry_data[:secondary_not_found] = (retry_data[:current_location] === Azure::Storage::Common::StorageLocation::SECONDARY) && response.status_code === 404;
216
+ retry_data[:secondary_not_found] =
217
+ ((retry_data[:current_location] === Azure::Storage::Common::StorageLocation::SECONDARY) &&
218
+ response.status_code === 404);
216
219
 
217
220
  if retry_data[:secondary_not_found]
218
221
  retry_data[:status_code] = 500
@@ -238,11 +241,6 @@ module Azure::Storage::Common::Core::Filter
238
241
  retry_data[:retryable] = false;
239
242
  end
240
243
 
241
- if (retry_data[:status_code] == 404)
242
- retry_data[:retryable] = true;
243
- return true;
244
- end
245
-
246
244
  # When absorb_conditional_errors_on_retry is set (for append blob)
247
245
  if (@request_options[:absorb_conditional_errors_on_retry])
248
246
  if (retry_data[:status_code] == 412)
@@ -48,6 +48,10 @@ module Azure::Storage::Common::Core
48
48
  def build_http(uri)
49
49
  ssl_options = {}
50
50
  if uri.is_a?(URI) && uri.scheme.downcase == "https"
51
+ ssl_options[:version] = self.ssl_version if self.ssl_version
52
+ # min_version and max_version only supported in ruby 2.5
53
+ ssl_options[:min_version] = self.ssl_min_version if self.ssl_min_version
54
+ ssl_options[:max_version] = self.ssl_max_version if self.ssl_max_version
51
55
  ssl_options[:ca_file] = self.ca_file if self.ca_file
52
56
  ssl_options[:verify] = true
53
57
  end
@@ -0,0 +1,64 @@
1
+ # frozen_string_literal: true
2
+
3
+ #-------------------------------------------------------------------------
4
+ # # Copyright (c) Microsoft and contributors. All rights reserved.
5
+ #
6
+ # The MIT License(MIT)
7
+
8
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
9
+ # of this software and associated documentation files(the "Software"), to deal
10
+ # in the Software without restriction, including without limitation the rights
11
+ # to use, copy, modify, merge, publish, distribute, sublicense, and / or sell
12
+ # copies of the Software, and to permit persons to whom the Software is
13
+ # furnished to do so, subject to the following conditions :
14
+
15
+ # The above copyright notice and this permission notice shall be included in
16
+ # all copies or substantial portions of the Software.
17
+
18
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE
21
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24
+ # THE SOFTWARE.
25
+ #--------------------------------------------------------------------------
26
+ require "azure/core"
27
+
28
+ module Azure::Storage::Common::Core
29
+ class TokenCredential
30
+
31
+ # Public: Initializes an instance of [Azure::Storage::Common::Core::TokenCredential]
32
+ #
33
+ # ==== Attributes
34
+ #
35
+ # * +token+ - String. The initial access token.
36
+ #
37
+ def initialize(token)
38
+ @token = token
39
+ @mutex = Mutex.new
40
+ end
41
+
42
+ # Public: Gets the access token
43
+ #
44
+ # Note: Providing this getter under the protect of a mutex
45
+ #
46
+ def token
47
+ @mutex.synchronize do
48
+ @token
49
+ end
50
+ end
51
+
52
+ # Public: Renews the access token
53
+ #
54
+ # ==== Attributes
55
+ #
56
+ # * +new_token+ - String. The new access token.
57
+ #
58
+ def renew_token(new_token)
59
+ @mutex.synchronize do
60
+ @token = new_token
61
+ end
62
+ end
63
+ end
64
+ end
@@ -30,7 +30,7 @@ require "azure/storage/common/version"
30
30
  module Azure::Storage::Common
31
31
  module Default
32
32
  # Default REST service (STG) version number. This is used only for SAS generator.
33
- STG_VERSION = "2016-05-31"
33
+ STG_VERSION = "2017-11-09"
34
34
 
35
35
  # The number of default concurrent requests for parallel operation.
36
36
  DEFAULT_PARALLEL_OPERATION_THREAD_COUNT = 1
@@ -30,8 +30,8 @@ module Azure
30
30
  class Version
31
31
  # Fields represent the parts defined in http://semver.org/
32
32
  MAJOR = 1 unless defined? MAJOR
33
- MINOR = 0 unless defined? MINOR
34
- UPDATE = 1 unless defined? UPDATE
33
+ MINOR = 1 unless defined? MINOR
34
+ UPDATE = 0 unless defined? UPDATE
35
35
 
36
36
  class << self
37
37
  # @return [String]
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: azure-storage-common
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Microsoft Corporation
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-01-17 00:00:00.000000000 Z
11
+ date: 2018-12-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: azure-core
@@ -166,6 +166,7 @@ files:
166
166
  - lib/azure/storage/common/core/auth/shared_access_signature_generator.rb
167
167
  - lib/azure/storage/common/core/auth/shared_access_signature_signer.rb
168
168
  - lib/azure/storage/common/core/auth/shared_key.rb
169
+ - lib/azure/storage/common/core/auth/token_signer.rb
169
170
  - lib/azure/storage/common/core/autoload.rb
170
171
  - lib/azure/storage/common/core/error.rb
171
172
  - lib/azure/storage/common/core/filter/exponential_retry_filter.rb
@@ -173,6 +174,7 @@ files:
173
174
  - lib/azure/storage/common/core/filter/retry_filter.rb
174
175
  - lib/azure/storage/common/core/http_client.rb
175
176
  - lib/azure/storage/common/core/sr.rb
177
+ - lib/azure/storage/common/core/token_credential.rb
176
178
  - lib/azure/storage/common/core/utility.rb
177
179
  - lib/azure/storage/common/default.rb
178
180
  - lib/azure/storage/common/service/access_policy.rb