azure 0.7.3 → 0.7.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +13 -5
- data/Rakefile +1 -1
- data/azure.gemspec +1 -0
- data/lib/azure/base_management/serialization.rb +1 -0
- data/lib/azure/client_services.rb +2 -1
- data/lib/azure/version.rb +1 -1
- data/lib/azure.rb +0 -10
- metadata +56 -59
- data/lib/azure/core/auth/authorizer.rb +0 -36
- data/lib/azure/core/auth/shared_key.rb +0 -118
- data/lib/azure/core/auth/shared_key_lite.rb +0 -48
- data/lib/azure/core/auth/signer.rb +0 -51
- data/lib/azure/core/error.rb +0 -21
- data/lib/azure/core/filtered_service.rb +0 -45
- data/lib/azure/core/http/debug_filter.rb +0 -36
- data/lib/azure/core/http/http_error.rb +0 -86
- data/lib/azure/core/http/http_filter.rb +0 -53
- data/lib/azure/core/http/http_request.rb +0 -162
- data/lib/azure/core/http/http_response.rb +0 -96
- data/lib/azure/core/http/retry_policy.rb +0 -74
- data/lib/azure/core/http/signer_filter.rb +0 -33
- data/lib/azure/core/service.rb +0 -47
- data/lib/azure/core/signed_service.rb +0 -45
- data/lib/azure/core/utility.rb +0 -244
checksums.yaml
CHANGED
@@ -1,7 +1,15 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
|
2
|
+
!binary "U0hBMQ==":
|
3
|
+
metadata.gz: !binary |-
|
4
|
+
MWYzOGVlNTBhYTU2YzcyMWEyM2RkZDMyNTI1M2VmMWY0YzM3MzdmOA==
|
5
|
+
data.tar.gz: !binary |-
|
6
|
+
YTNkY2FmZjEwNGZlOGIwZGM2ZmJhZTYzYTdiYmNiZTZkNDU1Zjc4Ng==
|
5
7
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
|
8
|
+
metadata.gz: !binary |-
|
9
|
+
ZmE2ODY3OGY2MDA0NmNkMmMzN2UyZjY4ZGIxMmUxZmYzYzZmMWUwM2I4NmUy
|
10
|
+
MjM1NGYzMmNmN2JjNmU5MmMzNWVlYWFhOWI0YWY0MmEyOWRhNzVkN2VkZDQz
|
11
|
+
M2I4ZDFlOTY1MTZiNmQ4NThkNzc5OGNiNTMyYjIzYjFlMDUyZDY=
|
12
|
+
data.tar.gz: !binary |-
|
13
|
+
Y2Y0NmU5MGQ2YWRhZTE3ODZlNDQxMWFkMzRhZGQ0MWVhZmI2NDlmNTQwYzEx
|
14
|
+
OGY4NGQxMWMyZTVkMjRhYWJhMjA5ZjE1ZDJlMGEwYjc3N2NhZWVmZTdlOGRk
|
15
|
+
YWRhZjM0ZDY4NGUxZWUxYTNkZGFiMmNlMGZlYzQ0NzY2OTBhZWY=
|
data/Rakefile
CHANGED
@@ -104,7 +104,7 @@ namespace :test do
|
|
104
104
|
t.test_files = Dir['test/integration/**/*_test.rb'].reject do |path|
|
105
105
|
# Reject the test paths those are not yet VCR recorded
|
106
106
|
# Following three are Azure-Storage gem features and need to be removed when we take dependency on azure-storage gem
|
107
|
-
path.include?('blob') || path.include?('queue') || path.include?('table')
|
107
|
+
path.include?('/blob/') || path.include?('/queue/') || path.include?('/table/')
|
108
108
|
end
|
109
109
|
t.verbose = true
|
110
110
|
t.libs = %w(lib test)
|
data/azure.gemspec
CHANGED
@@ -32,6 +32,7 @@ Gem::Specification.new do |s|
|
|
32
32
|
s.required_ruby_version = '>= 1.9.3'
|
33
33
|
|
34
34
|
s.add_runtime_dependency('addressable', '~> 2.3')
|
35
|
+
s.add_runtime_dependency('azure-core', '~> 0.1')
|
35
36
|
s.add_runtime_dependency('faraday', '~> 0.9')
|
36
37
|
s.add_runtime_dependency('faraday_middleware', '~> 0.10')
|
37
38
|
s.add_runtime_dependency('json', '~> 1.8')
|
data/lib/azure/version.rb
CHANGED
data/lib/azure.rb
CHANGED
@@ -30,7 +30,6 @@ module Azure
|
|
30
30
|
autoload :Default, 'azure/default'
|
31
31
|
autoload :HttpClient, 'azure/http_client'
|
32
32
|
autoload :Version, 'azure/version'
|
33
|
-
autoload :HttpResponseHelper, 'azure/http_response_helper'
|
34
33
|
|
35
34
|
# helpers because the naming is far too verbose
|
36
35
|
autoload :BaseManagementService, 'azure/base_management/base_management_service'
|
@@ -63,15 +62,6 @@ module Azure
|
|
63
62
|
autoload :CloudService, 'azure/cloud_service_management/cloud_service'
|
64
63
|
end
|
65
64
|
|
66
|
-
module Core
|
67
|
-
autoload :Utility, 'azure/core/utility'
|
68
|
-
autoload :Logger, 'azure/core/utility'
|
69
|
-
autoload :Error, 'azure/core/error'
|
70
|
-
autoload :Service, 'azure/core/service'
|
71
|
-
autoload :FilteredService, 'azure/core/filtered_service'
|
72
|
-
autoload :SignedService, 'azure/core/signed_service'
|
73
|
-
end
|
74
|
-
|
75
65
|
module Queue
|
76
66
|
autoload :QueueService, 'azure/queue/queue_service'
|
77
67
|
autoload :Message, 'azure/queue/message'
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: azure
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.7.
|
4
|
+
version: 0.7.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Microsoft Corporation
|
@@ -9,250 +9,264 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2016-04-
|
12
|
+
date: 2016-04-19 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: addressable
|
16
16
|
requirement: !ruby/object:Gem::Requirement
|
17
17
|
requirements:
|
18
|
-
- -
|
18
|
+
- - ~>
|
19
19
|
- !ruby/object:Gem::Version
|
20
20
|
version: '2.3'
|
21
21
|
type: :runtime
|
22
22
|
prerelease: false
|
23
23
|
version_requirements: !ruby/object:Gem::Requirement
|
24
24
|
requirements:
|
25
|
-
- -
|
25
|
+
- - ~>
|
26
26
|
- !ruby/object:Gem::Version
|
27
27
|
version: '2.3'
|
28
|
+
- !ruby/object:Gem::Dependency
|
29
|
+
name: azure-core
|
30
|
+
requirement: !ruby/object:Gem::Requirement
|
31
|
+
requirements:
|
32
|
+
- - ~>
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: '0.1'
|
35
|
+
type: :runtime
|
36
|
+
prerelease: false
|
37
|
+
version_requirements: !ruby/object:Gem::Requirement
|
38
|
+
requirements:
|
39
|
+
- - ~>
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
version: '0.1'
|
28
42
|
- !ruby/object:Gem::Dependency
|
29
43
|
name: faraday
|
30
44
|
requirement: !ruby/object:Gem::Requirement
|
31
45
|
requirements:
|
32
|
-
- -
|
46
|
+
- - ~>
|
33
47
|
- !ruby/object:Gem::Version
|
34
48
|
version: '0.9'
|
35
49
|
type: :runtime
|
36
50
|
prerelease: false
|
37
51
|
version_requirements: !ruby/object:Gem::Requirement
|
38
52
|
requirements:
|
39
|
-
- -
|
53
|
+
- - ~>
|
40
54
|
- !ruby/object:Gem::Version
|
41
55
|
version: '0.9'
|
42
56
|
- !ruby/object:Gem::Dependency
|
43
57
|
name: faraday_middleware
|
44
58
|
requirement: !ruby/object:Gem::Requirement
|
45
59
|
requirements:
|
46
|
-
- -
|
60
|
+
- - ~>
|
47
61
|
- !ruby/object:Gem::Version
|
48
62
|
version: '0.10'
|
49
63
|
type: :runtime
|
50
64
|
prerelease: false
|
51
65
|
version_requirements: !ruby/object:Gem::Requirement
|
52
66
|
requirements:
|
53
|
-
- -
|
67
|
+
- - ~>
|
54
68
|
- !ruby/object:Gem::Version
|
55
69
|
version: '0.10'
|
56
70
|
- !ruby/object:Gem::Dependency
|
57
71
|
name: json
|
58
72
|
requirement: !ruby/object:Gem::Requirement
|
59
73
|
requirements:
|
60
|
-
- -
|
74
|
+
- - ~>
|
61
75
|
- !ruby/object:Gem::Version
|
62
76
|
version: '1.8'
|
63
77
|
type: :runtime
|
64
78
|
prerelease: false
|
65
79
|
version_requirements: !ruby/object:Gem::Requirement
|
66
80
|
requirements:
|
67
|
-
- -
|
81
|
+
- - ~>
|
68
82
|
- !ruby/object:Gem::Version
|
69
83
|
version: '1.8'
|
70
84
|
- !ruby/object:Gem::Dependency
|
71
85
|
name: mime-types
|
72
86
|
requirement: !ruby/object:Gem::Requirement
|
73
87
|
requirements:
|
74
|
-
- -
|
88
|
+
- - ! '>='
|
75
89
|
- !ruby/object:Gem::Version
|
76
90
|
version: '1'
|
77
|
-
- -
|
91
|
+
- - <
|
78
92
|
- !ruby/object:Gem::Version
|
79
93
|
version: '3.0'
|
80
94
|
type: :runtime
|
81
95
|
prerelease: false
|
82
96
|
version_requirements: !ruby/object:Gem::Requirement
|
83
97
|
requirements:
|
84
|
-
- -
|
98
|
+
- - ! '>='
|
85
99
|
- !ruby/object:Gem::Version
|
86
100
|
version: '1'
|
87
|
-
- -
|
101
|
+
- - <
|
88
102
|
- !ruby/object:Gem::Version
|
89
103
|
version: '3.0'
|
90
104
|
- !ruby/object:Gem::Dependency
|
91
105
|
name: nokogiri
|
92
106
|
requirement: !ruby/object:Gem::Requirement
|
93
107
|
requirements:
|
94
|
-
- -
|
108
|
+
- - ~>
|
95
109
|
- !ruby/object:Gem::Version
|
96
110
|
version: '1.6'
|
97
111
|
type: :runtime
|
98
112
|
prerelease: false
|
99
113
|
version_requirements: !ruby/object:Gem::Requirement
|
100
114
|
requirements:
|
101
|
-
- -
|
115
|
+
- - ~>
|
102
116
|
- !ruby/object:Gem::Version
|
103
117
|
version: '1.6'
|
104
118
|
- !ruby/object:Gem::Dependency
|
105
119
|
name: systemu
|
106
120
|
requirement: !ruby/object:Gem::Requirement
|
107
121
|
requirements:
|
108
|
-
- -
|
122
|
+
- - ~>
|
109
123
|
- !ruby/object:Gem::Version
|
110
124
|
version: '2.6'
|
111
125
|
type: :runtime
|
112
126
|
prerelease: false
|
113
127
|
version_requirements: !ruby/object:Gem::Requirement
|
114
128
|
requirements:
|
115
|
-
- -
|
129
|
+
- - ~>
|
116
130
|
- !ruby/object:Gem::Version
|
117
131
|
version: '2.6'
|
118
132
|
- !ruby/object:Gem::Dependency
|
119
133
|
name: thor
|
120
134
|
requirement: !ruby/object:Gem::Requirement
|
121
135
|
requirements:
|
122
|
-
- -
|
136
|
+
- - ~>
|
123
137
|
- !ruby/object:Gem::Version
|
124
138
|
version: '0.19'
|
125
139
|
type: :runtime
|
126
140
|
prerelease: false
|
127
141
|
version_requirements: !ruby/object:Gem::Requirement
|
128
142
|
requirements:
|
129
|
-
- -
|
143
|
+
- - ~>
|
130
144
|
- !ruby/object:Gem::Version
|
131
145
|
version: '0.19'
|
132
146
|
- !ruby/object:Gem::Dependency
|
133
147
|
name: uuid
|
134
148
|
requirement: !ruby/object:Gem::Requirement
|
135
149
|
requirements:
|
136
|
-
- -
|
150
|
+
- - ~>
|
137
151
|
- !ruby/object:Gem::Version
|
138
152
|
version: '2.0'
|
139
153
|
type: :runtime
|
140
154
|
prerelease: false
|
141
155
|
version_requirements: !ruby/object:Gem::Requirement
|
142
156
|
requirements:
|
143
|
-
- -
|
157
|
+
- - ~>
|
144
158
|
- !ruby/object:Gem::Version
|
145
159
|
version: '2.0'
|
146
160
|
- !ruby/object:Gem::Dependency
|
147
161
|
name: dotenv
|
148
162
|
requirement: !ruby/object:Gem::Requirement
|
149
163
|
requirements:
|
150
|
-
- -
|
164
|
+
- - ~>
|
151
165
|
- !ruby/object:Gem::Version
|
152
166
|
version: '2.0'
|
153
167
|
type: :development
|
154
168
|
prerelease: false
|
155
169
|
version_requirements: !ruby/object:Gem::Requirement
|
156
170
|
requirements:
|
157
|
-
- -
|
171
|
+
- - ~>
|
158
172
|
- !ruby/object:Gem::Version
|
159
173
|
version: '2.0'
|
160
174
|
- !ruby/object:Gem::Dependency
|
161
175
|
name: minitest
|
162
176
|
requirement: !ruby/object:Gem::Requirement
|
163
177
|
requirements:
|
164
|
-
- -
|
178
|
+
- - ~>
|
165
179
|
- !ruby/object:Gem::Version
|
166
180
|
version: '5'
|
167
181
|
type: :development
|
168
182
|
prerelease: false
|
169
183
|
version_requirements: !ruby/object:Gem::Requirement
|
170
184
|
requirements:
|
171
|
-
- -
|
185
|
+
- - ~>
|
172
186
|
- !ruby/object:Gem::Version
|
173
187
|
version: '5'
|
174
188
|
- !ruby/object:Gem::Dependency
|
175
189
|
name: minitest-reporters
|
176
190
|
requirement: !ruby/object:Gem::Requirement
|
177
191
|
requirements:
|
178
|
-
- -
|
192
|
+
- - ~>
|
179
193
|
- !ruby/object:Gem::Version
|
180
194
|
version: '1'
|
181
195
|
type: :development
|
182
196
|
prerelease: false
|
183
197
|
version_requirements: !ruby/object:Gem::Requirement
|
184
198
|
requirements:
|
185
|
-
- -
|
199
|
+
- - ~>
|
186
200
|
- !ruby/object:Gem::Version
|
187
201
|
version: '1'
|
188
202
|
- !ruby/object:Gem::Dependency
|
189
203
|
name: mocha
|
190
204
|
requirement: !ruby/object:Gem::Requirement
|
191
205
|
requirements:
|
192
|
-
- -
|
206
|
+
- - ~>
|
193
207
|
- !ruby/object:Gem::Version
|
194
208
|
version: '1.0'
|
195
209
|
type: :development
|
196
210
|
prerelease: false
|
197
211
|
version_requirements: !ruby/object:Gem::Requirement
|
198
212
|
requirements:
|
199
|
-
- -
|
213
|
+
- - ~>
|
200
214
|
- !ruby/object:Gem::Version
|
201
215
|
version: '1.0'
|
202
216
|
- !ruby/object:Gem::Dependency
|
203
217
|
name: rake
|
204
218
|
requirement: !ruby/object:Gem::Requirement
|
205
219
|
requirements:
|
206
|
-
- -
|
220
|
+
- - ~>
|
207
221
|
- !ruby/object:Gem::Version
|
208
222
|
version: '10.0'
|
209
223
|
type: :development
|
210
224
|
prerelease: false
|
211
225
|
version_requirements: !ruby/object:Gem::Requirement
|
212
226
|
requirements:
|
213
|
-
- -
|
227
|
+
- - ~>
|
214
228
|
- !ruby/object:Gem::Version
|
215
229
|
version: '10.0'
|
216
230
|
- !ruby/object:Gem::Dependency
|
217
231
|
name: timecop
|
218
232
|
requirement: !ruby/object:Gem::Requirement
|
219
233
|
requirements:
|
220
|
-
- -
|
234
|
+
- - ~>
|
221
235
|
- !ruby/object:Gem::Version
|
222
236
|
version: '0.7'
|
223
237
|
type: :development
|
224
238
|
prerelease: false
|
225
239
|
version_requirements: !ruby/object:Gem::Requirement
|
226
240
|
requirements:
|
227
|
-
- -
|
241
|
+
- - ~>
|
228
242
|
- !ruby/object:Gem::Version
|
229
243
|
version: '0.7'
|
230
244
|
- !ruby/object:Gem::Dependency
|
231
245
|
name: yard
|
232
246
|
requirement: !ruby/object:Gem::Requirement
|
233
247
|
requirements:
|
234
|
-
- -
|
248
|
+
- - ~>
|
235
249
|
- !ruby/object:Gem::Version
|
236
250
|
version: '0.8'
|
237
251
|
type: :development
|
238
252
|
prerelease: false
|
239
253
|
version_requirements: !ruby/object:Gem::Requirement
|
240
254
|
requirements:
|
241
|
-
- -
|
255
|
+
- - ~>
|
242
256
|
- !ruby/object:Gem::Version
|
243
257
|
version: '0.8'
|
244
258
|
- !ruby/object:Gem::Dependency
|
245
259
|
name: vcr
|
246
260
|
requirement: !ruby/object:Gem::Requirement
|
247
261
|
requirements:
|
248
|
-
- -
|
262
|
+
- - ~>
|
249
263
|
- !ruby/object:Gem::Version
|
250
264
|
version: '3.0'
|
251
265
|
type: :development
|
252
266
|
prerelease: false
|
253
267
|
version_requirements: !ruby/object:Gem::Requirement
|
254
268
|
requirements:
|
255
|
-
- -
|
269
|
+
- - ~>
|
256
270
|
- !ruby/object:Gem::Version
|
257
271
|
version: '3.0'
|
258
272
|
description: Microsoft Azure Client Library for Ruby
|
@@ -262,7 +276,7 @@ executables:
|
|
262
276
|
extensions: []
|
263
277
|
extra_rdoc_files: []
|
264
278
|
files:
|
265
|
-
-
|
279
|
+
- .env_sample
|
266
280
|
- Gemfile
|
267
281
|
- LICENSE.txt
|
268
282
|
- Rakefile
|
@@ -287,22 +301,6 @@ files:
|
|
287
301
|
- lib/azure/cloud_service_management/cloud_service_management_service.rb
|
288
302
|
- lib/azure/cloud_service_management/serialization.rb
|
289
303
|
- lib/azure/configurable.rb
|
290
|
-
- lib/azure/core/auth/authorizer.rb
|
291
|
-
- lib/azure/core/auth/shared_key.rb
|
292
|
-
- lib/azure/core/auth/shared_key_lite.rb
|
293
|
-
- lib/azure/core/auth/signer.rb
|
294
|
-
- lib/azure/core/error.rb
|
295
|
-
- lib/azure/core/filtered_service.rb
|
296
|
-
- lib/azure/core/http/debug_filter.rb
|
297
|
-
- lib/azure/core/http/http_error.rb
|
298
|
-
- lib/azure/core/http/http_filter.rb
|
299
|
-
- lib/azure/core/http/http_request.rb
|
300
|
-
- lib/azure/core/http/http_response.rb
|
301
|
-
- lib/azure/core/http/retry_policy.rb
|
302
|
-
- lib/azure/core/http/signer_filter.rb
|
303
|
-
- lib/azure/core/service.rb
|
304
|
-
- lib/azure/core/signed_service.rb
|
305
|
-
- lib/azure/core/utility.rb
|
306
304
|
- lib/azure/default.rb
|
307
305
|
- lib/azure/http_client.rb
|
308
306
|
- lib/azure/http_response_helper.rb
|
@@ -383,19 +381,18 @@ require_paths:
|
|
383
381
|
- lib
|
384
382
|
required_ruby_version: !ruby/object:Gem::Requirement
|
385
383
|
requirements:
|
386
|
-
- -
|
384
|
+
- - ! '>='
|
387
385
|
- !ruby/object:Gem::Version
|
388
386
|
version: 1.9.3
|
389
387
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
390
388
|
requirements:
|
391
|
-
- -
|
389
|
+
- - ! '>='
|
392
390
|
- !ruby/object:Gem::Version
|
393
391
|
version: '0'
|
394
392
|
requirements: []
|
395
393
|
rubyforge_project:
|
396
|
-
rubygems_version: 2.4.
|
394
|
+
rubygems_version: 2.4.5
|
397
395
|
signing_key:
|
398
396
|
specification_version: 4
|
399
397
|
summary: Official ruby client library to consume Microsoft Azure services.
|
400
398
|
test_files: []
|
401
|
-
has_rdoc:
|
@@ -1,36 +0,0 @@
|
|
1
|
-
#-------------------------------------------------------------------------
|
2
|
-
# # Copyright (c) Microsoft and contributors. All rights reserved.
|
3
|
-
#
|
4
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
5
|
-
# you may not use this file except in compliance with the License.
|
6
|
-
# You may obtain a copy of the License at
|
7
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
8
|
-
#
|
9
|
-
# Unless required by applicable law or agreed to in writing, software
|
10
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
-
# See the License for the specific language governing permissions and
|
13
|
-
# limitations under the License.
|
14
|
-
#--------------------------------------------------------------------------
|
15
|
-
require "azure/core/configuration"
|
16
|
-
|
17
|
-
module Azure
|
18
|
-
module Core
|
19
|
-
module Auth
|
20
|
-
class Authorizer
|
21
|
-
# Public: Signs an HTTP request before it's made, by adding the
|
22
|
-
# Authorization header
|
23
|
-
#
|
24
|
-
# request - An Azure::Core::HttpRequest that hasn't been signed
|
25
|
-
# signer - A signing strategy, such as Azure::Table::Auth::SharedKey
|
26
|
-
#
|
27
|
-
# Returns the modified request
|
28
|
-
def sign(request, signer)
|
29
|
-
signature = signer.sign(request.method, request.uri, request.headers)
|
30
|
-
request.headers['Authorization'] = "#{signer.name} #{signature}"
|
31
|
-
request
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end
|
35
|
-
end
|
36
|
-
end
|
@@ -1,118 +0,0 @@
|
|
1
|
-
#-------------------------------------------------------------------------
|
2
|
-
# # Copyright (c) Microsoft and contributors. All rights reserved.
|
3
|
-
#
|
4
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
5
|
-
# you may not use this file except in compliance with the License.
|
6
|
-
# You may obtain a copy of the License at
|
7
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
8
|
-
#
|
9
|
-
# Unless required by applicable law or agreed to in writing, software
|
10
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
-
# See the License for the specific language governing permissions and
|
13
|
-
# limitations under the License.
|
14
|
-
#--------------------------------------------------------------------------
|
15
|
-
require 'cgi'
|
16
|
-
require 'azure/core/auth/signer'
|
17
|
-
|
18
|
-
module Azure
|
19
|
-
module Core
|
20
|
-
module Auth
|
21
|
-
class SharedKey < Signer
|
22
|
-
# The Azure account's name.
|
23
|
-
attr :account_name
|
24
|
-
|
25
|
-
# Initialize the Signer.
|
26
|
-
#
|
27
|
-
# @param account_name [String] The account name. Defaults to the one in the
|
28
|
-
# global configuration.
|
29
|
-
# @param access_key [String] The access_key encoded in Base64. Defaults to the
|
30
|
-
# one in the global configuration.
|
31
|
-
def initialize(account_name=Azure.storage_account_name, access_key=Azure.storage_access_key)
|
32
|
-
@account_name = account_name
|
33
|
-
super(access_key)
|
34
|
-
end
|
35
|
-
|
36
|
-
# The name of the strategy.
|
37
|
-
#
|
38
|
-
# @return [String]
|
39
|
-
def name
|
40
|
-
'SharedKey'
|
41
|
-
end
|
42
|
-
|
43
|
-
# Create the signature for the request parameters
|
44
|
-
#
|
45
|
-
# @param method [Symbol] HTTP request method.
|
46
|
-
# @param uri [URI] URI of the request we're signing.
|
47
|
-
# @param headers [Hash] HTTP request headers.
|
48
|
-
#
|
49
|
-
# @return [String] base64 encoded signature
|
50
|
-
def sign(method, uri, headers)
|
51
|
-
"#{account_name}:#{super(signable_string(method, uri, headers))}"
|
52
|
-
end
|
53
|
-
|
54
|
-
# Sign the request
|
55
|
-
#
|
56
|
-
# @param req [Azure::Core::Http::HttpRequest] HTTP request to sign
|
57
|
-
#
|
58
|
-
# @return [Azure::Core::Http::HttpRequest]
|
59
|
-
def sign_request(req)
|
60
|
-
req.headers['Authorization'] = "#{name} #{sign(req.method, req.uri, req.headers)}"
|
61
|
-
req
|
62
|
-
end
|
63
|
-
|
64
|
-
# Generate the string to sign.
|
65
|
-
#
|
66
|
-
# @param method [Symbol] HTTP request method.
|
67
|
-
# @param uri [URI] URI of the request we're signing.
|
68
|
-
# @param headers [Hash] HTTP request headers.
|
69
|
-
#
|
70
|
-
# @return [String]
|
71
|
-
def signable_string(method, uri, headers)
|
72
|
-
[
|
73
|
-
method.to_s.upcase,
|
74
|
-
headers.fetch('Content-Encoding', ''),
|
75
|
-
headers.fetch('Content-Language', ''),
|
76
|
-
headers.fetch('Content-Length', ''),
|
77
|
-
headers.fetch('Content-MD5', ''),
|
78
|
-
headers.fetch('Content-Type', ''),
|
79
|
-
headers.fetch('Date', ''),
|
80
|
-
headers.fetch('If-Modified-Since', ''),
|
81
|
-
headers.fetch('If-Match', ''),
|
82
|
-
headers.fetch('If-None-Match', ''),
|
83
|
-
headers.fetch('If-Unmodified-Since', ''),
|
84
|
-
headers.fetch('Range', ''),
|
85
|
-
canonicalized_headers(headers),
|
86
|
-
canonicalized_resource(uri)
|
87
|
-
].join("\n")
|
88
|
-
end
|
89
|
-
|
90
|
-
# Calculate the Canonicalized Headers string for a request.
|
91
|
-
#
|
92
|
-
# @param headers [Hash] HTTP request headers.
|
93
|
-
#
|
94
|
-
# @return [String] a string with the canonicalized headers.
|
95
|
-
def canonicalized_headers(headers)
|
96
|
-
headers = headers.map { |k,v| [k.to_s.downcase, v] }
|
97
|
-
headers.select! { |k,v| k =~ /^x-ms-/ }
|
98
|
-
headers.sort_by! { |(k,v)| k }
|
99
|
-
headers.map! { |k,v| '%s:%s' % [k, v] }
|
100
|
-
headers.map! { |h| h.gsub(/\s+/, ' ') }.join("\n")
|
101
|
-
end
|
102
|
-
|
103
|
-
# Calculate the Canonicalized Resource string for a request.
|
104
|
-
#
|
105
|
-
# @param uri [URI] URI of the request we're signing.
|
106
|
-
#
|
107
|
-
# @return [String] a string with the canonicalized resource.
|
108
|
-
def canonicalized_resource(uri)
|
109
|
-
resource = '/' + account_name + (uri.path.empty? ? '/' : uri.path)
|
110
|
-
params = CGI.parse(uri.query.to_s).map { |k,v| [k.downcase, v] }
|
111
|
-
params.sort_by! { |k,v| k }
|
112
|
-
params.map! { |k,v| '%s:%s' % [k, v.map(&:strip).sort.join(',')] }
|
113
|
-
[resource, *params].join("\n")
|
114
|
-
end
|
115
|
-
end
|
116
|
-
end
|
117
|
-
end
|
118
|
-
end
|
@@ -1,48 +0,0 @@
|
|
1
|
-
#-------------------------------------------------------------------------
|
2
|
-
# # Copyright (c) Microsoft and contributors. All rights reserved.
|
3
|
-
#
|
4
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
5
|
-
# you may not use this file except in compliance with the License.
|
6
|
-
# You may obtain a copy of the License at
|
7
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
8
|
-
#
|
9
|
-
# Unless required by applicable law or agreed to in writing, software
|
10
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
-
# See the License for the specific language governing permissions and
|
13
|
-
# limitations under the License.
|
14
|
-
#--------------------------------------------------------------------------
|
15
|
-
require "azure/core/auth/shared_key"
|
16
|
-
|
17
|
-
module Azure
|
18
|
-
module Core
|
19
|
-
module Auth
|
20
|
-
class SharedKeyLite < SharedKey
|
21
|
-
# The name of the strategy.
|
22
|
-
#
|
23
|
-
# @return [String]
|
24
|
-
def name
|
25
|
-
'SharedKeyLite'
|
26
|
-
end
|
27
|
-
|
28
|
-
# Generate the string to sign.
|
29
|
-
#
|
30
|
-
# @param method [Symbol] The HTTP request method.
|
31
|
-
# @param uri [URI] The URI of the request we're signing.
|
32
|
-
# @param headers [Hash] A Hash of HTTP request headers.
|
33
|
-
#
|
34
|
-
# Returns a plain text string.
|
35
|
-
def signable_string(method, uri, headers)
|
36
|
-
[
|
37
|
-
method.to_s.upcase,
|
38
|
-
headers.fetch('Content-MD5', ''),
|
39
|
-
headers.fetch('Content-Type', ''),
|
40
|
-
headers.fetch('Date') { raise IndexError, 'Headers must include Date' },
|
41
|
-
canonicalized_headers(headers),
|
42
|
-
canonicalized_resource(uri)
|
43
|
-
].join("\n")
|
44
|
-
end
|
45
|
-
end
|
46
|
-
end
|
47
|
-
end
|
48
|
-
end
|