fog-brightbox 0.14.0 → 0.15.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/CHANGELOG.md +11 -0
- data/fog-brightbox.gemspec +1 -0
- data/lib/fog/brightbox/requests/storage/get_object_https_url.rb +0 -57
- data/lib/fog/brightbox/storage.rb +61 -1
- data/lib/fog/brightbox/version.rb +1 -1
- data/spec/fog/storage/brightbox_spec.rb +22 -0
- metadata +17 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 826b4f7f6d48136ffaaf14d0425cc95d4b68de3cf9b6d20c299cb652d7712534
|
4
|
+
data.tar.gz: f912008723a966a900c88e628754eb73148ee6f0c860e160526ec2cfae6f4473
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: be678b189da4225bb77a43e62717fb03ce64a462fd70852e8e631664ee6ed893f4993be15a95c02f3ad870bdf0711aa9085ca05ba9dd8b7adedd104dac8aae8e
|
7
|
+
data.tar.gz: 815fb87c8d71c39a461007d086e1990ee6074d6a73b941380324472469c7d2ffddf00d41eb0feaea9763d39c1e2f0227f6441325e48e05a32e362c68e7195dc2
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,14 @@
|
|
1
|
+
### 0.15.0 / 2018-06-14
|
2
|
+
|
3
|
+
Bug fixes:
|
4
|
+
|
5
|
+
* Attempting to generate a temporary URL for a storage object would fail with
|
6
|
+
unclear message. Now a `Fog::Brightbox::Storage::ManagementUrlUnknown` is
|
7
|
+
raised instead. It must be either configured OR an authentication request
|
8
|
+
made before so the management URL is received from the server.
|
9
|
+
* `:brightbox_storage_management_url` is now whitelisted to be passed in to the
|
10
|
+
configuration to avoid the authentication previously required.
|
11
|
+
|
1
12
|
### 0.14.0 / 2017-10-30
|
2
13
|
|
3
14
|
Enhancements:
|
data/fog-brightbox.gemspec
CHANGED
@@ -22,6 +22,7 @@ Gem::Specification.new do |spec|
|
|
22
22
|
spec.add_dependency "fog-core", "~> 1.22"
|
23
23
|
spec.add_dependency "fog-json"
|
24
24
|
spec.add_dependency "inflecto", "~> 0.0.2"
|
25
|
+
spec.add_dependency "mime-types"
|
25
26
|
|
26
27
|
spec.add_development_dependency "bundler", "~> 1.3"
|
27
28
|
spec.add_development_dependency "minitest"
|
@@ -15,63 +15,6 @@ module Fog
|
|
15
15
|
def get_object_https_url(container, object, expires, options = {})
|
16
16
|
create_temp_url(container, object, expires, "GET", options.merge(:scheme => "https"))
|
17
17
|
end
|
18
|
-
|
19
|
-
# creates a temporary url
|
20
|
-
#
|
21
|
-
# @param container [String] Name of container containing object
|
22
|
-
# @param object [String] Name of object to get expiring url for
|
23
|
-
# @param expires_at [Time] An expiry time for this url
|
24
|
-
# @param method [String] The method to use for accessing the object (GET, PUT, HEAD)
|
25
|
-
# @param options [Hash] An optional options hash
|
26
|
-
# @option options [String] :scheme The scheme to use (http, https)
|
27
|
-
# @option options [String] :port A non standard port to use
|
28
|
-
#
|
29
|
-
# @return [String] url for object
|
30
|
-
#
|
31
|
-
# @raise [ArgumentError] if +storage_temp_key+ is not set in configuration
|
32
|
-
# @raise [ArgumentError] if +method+ is not valid
|
33
|
-
#
|
34
|
-
# @see http://docs.rackspace.com/files/api/v1/cf-devguide/content/Create_TempURL-d1a444.html
|
35
|
-
#
|
36
|
-
def create_temp_url(container, object, expires_at, method, options = {})
|
37
|
-
raise ArgumentError, "Storage must be instantiated with the :brightbox_temp_url_key option" if @config.storage_temp_key.nil?
|
38
|
-
|
39
|
-
# POST not allowed
|
40
|
-
allowed_methods = %w(GET PUT HEAD)
|
41
|
-
unless allowed_methods.include?(method)
|
42
|
-
raise ArgumentError.new("Invalid method '#{method}' specified. Valid methods are: #{allowed_methods.join(", ")}")
|
43
|
-
end
|
44
|
-
|
45
|
-
# This assumes we have access to the management URL at this point
|
46
|
-
destination_url = management_url.dup
|
47
|
-
object_path = destination_url.path
|
48
|
-
|
49
|
-
destination_url.scheme = options[:scheme] if options[:scheme]
|
50
|
-
destination_url.port = options[:port] if options[:port]
|
51
|
-
|
52
|
-
object_path_escaped = "#{object_path}/#{Fog::Storage::Brightbox.escape(container)}/#{Fog::Storage::Brightbox.escape(object, "/")}"
|
53
|
-
object_path_unescaped = "#{object_path}/#{Fog::Storage::Brightbox.escape(container)}/#{object}"
|
54
|
-
|
55
|
-
expiry_timestamp = expires_at.to_i
|
56
|
-
string_to_sign = [method, expiry_timestamp, object_path_unescaped].join("\n")
|
57
|
-
|
58
|
-
hmac = Fog::HMAC.new("sha1", @config.storage_temp_key)
|
59
|
-
sig = sig_to_hex(hmac.sign(string_to_sign))
|
60
|
-
|
61
|
-
destination_url.path = object_path_escaped
|
62
|
-
destination_url.query = URI.encode_www_form(:temp_url_sig => sig, :temp_url_expires => expiry_timestamp)
|
63
|
-
destination_url.to_s
|
64
|
-
end
|
65
|
-
|
66
|
-
private
|
67
|
-
|
68
|
-
def sig_to_hex(str)
|
69
|
-
str.unpack("C*").map { |c|
|
70
|
-
c.to_s(16)
|
71
|
-
}.map { |h|
|
72
|
-
h.size == 1 ? "0#{h}" : h
|
73
|
-
}.join
|
74
|
-
end
|
75
18
|
end
|
76
19
|
end
|
77
20
|
end
|
@@ -6,7 +6,8 @@ module Fog
|
|
6
6
|
recognizes :persistent, :brightbox_service_name,
|
7
7
|
:brightbox_storage_url,
|
8
8
|
:brightbox_service_type, :brightbox_tenant,
|
9
|
-
:brightbox_region, :brightbox_temp_url_key
|
9
|
+
:brightbox_region, :brightbox_temp_url_key,
|
10
|
+
:brightbox_storage_management_url
|
10
11
|
|
11
12
|
model_path "fog/brightbox/models/storage"
|
12
13
|
model :directory
|
@@ -123,8 +124,67 @@ module Fog
|
|
123
124
|
url.path.split("/")[2]
|
124
125
|
end
|
125
126
|
|
127
|
+
# creates a temporary url
|
128
|
+
#
|
129
|
+
# @param container [String] Name of container containing object
|
130
|
+
# @param object [String] Name of object to get expiring url for
|
131
|
+
# @param expires_at [Time] An expiry time for this url
|
132
|
+
# @param method [String] The method to use for accessing the object (GET, PUT, HEAD)
|
133
|
+
# @param options [Hash] An optional options hash
|
134
|
+
# @option options [String] :scheme The scheme to use (http, https)
|
135
|
+
# @option options [String] :port A non standard port to use
|
136
|
+
#
|
137
|
+
# @return [String] url for object
|
138
|
+
#
|
139
|
+
# @raise [ArgumentError] if +storage_temp_key+ is not set in configuration
|
140
|
+
# @raise [ArgumentError] if +method+ is not valid
|
141
|
+
#
|
142
|
+
# @see http://docs.rackspace.com/files/api/v1/cf-devguide/content/Create_TempURL-d1a444.html
|
143
|
+
#
|
144
|
+
def create_temp_url(container, object, expires_at, method, options = {})
|
145
|
+
raise ArgumentError, "Storage must be instantiated with the :brightbox_temp_url_key option" if @config.storage_temp_key.nil?
|
146
|
+
|
147
|
+
# POST not allowed
|
148
|
+
allowed_methods = %w(GET PUT HEAD)
|
149
|
+
unless allowed_methods.include?(method)
|
150
|
+
raise ArgumentError.new("Invalid method '#{method}' specified. Valid methods are: #{allowed_methods.join(", ")}")
|
151
|
+
end
|
152
|
+
|
153
|
+
if management_url.nil?
|
154
|
+
message = "Storage must be instantiated with the :brightbox_storage_management_url or you must authenticate first"
|
155
|
+
raise Fog::Brightbox::Storage::ManagementUrlUnknown, message
|
156
|
+
end
|
157
|
+
|
158
|
+
destination_url = management_url.dup
|
159
|
+
object_path = destination_url.path
|
160
|
+
|
161
|
+
destination_url.scheme = options[:scheme] if options[:scheme]
|
162
|
+
destination_url.port = options[:port] if options[:port]
|
163
|
+
|
164
|
+
object_path_escaped = "#{object_path}/#{Fog::Storage::Brightbox.escape(container)}/#{Fog::Storage::Brightbox.escape(object, "/")}"
|
165
|
+
object_path_unescaped = "#{object_path}/#{Fog::Storage::Brightbox.escape(container)}/#{object}"
|
166
|
+
|
167
|
+
expiry_timestamp = expires_at.to_i
|
168
|
+
string_to_sign = [method, expiry_timestamp, object_path_unescaped].join("\n")
|
169
|
+
|
170
|
+
hmac = Fog::HMAC.new("sha1", @config.storage_temp_key)
|
171
|
+
sig = sig_to_hex(hmac.sign(string_to_sign))
|
172
|
+
|
173
|
+
destination_url.path = object_path_escaped
|
174
|
+
destination_url.query = URI.encode_www_form(:temp_url_sig => sig, :temp_url_expires => expiry_timestamp)
|
175
|
+
destination_url.to_s
|
176
|
+
end
|
177
|
+
|
126
178
|
private
|
127
179
|
|
180
|
+
def sig_to_hex(str)
|
181
|
+
str.unpack("C*").map { |c|
|
182
|
+
c.to_s(16)
|
183
|
+
}.map { |h|
|
184
|
+
h.size == 1 ? "0#{h}" : h
|
185
|
+
}.join
|
186
|
+
end
|
187
|
+
|
128
188
|
def update_config_from_auth_response(response)
|
129
189
|
@config.update_tokens(response.access_token)
|
130
190
|
|
@@ -317,4 +317,26 @@ describe Fog::Storage::Brightbox do
|
|
317
317
|
service.create_temp_url(container, object, expiry_time, request_method, :scheme => "http", :port => 401)
|
318
318
|
end
|
319
319
|
end
|
320
|
+
|
321
|
+
describe "when initialised without management URL" do
|
322
|
+
before { skip unless RUBY_VERSION > "1.9.3" }
|
323
|
+
let(:temp_url_key) { "1234567890" }
|
324
|
+
let(:settings) do
|
325
|
+
{
|
326
|
+
:brightbox_client_id => "cli-12345",
|
327
|
+
:brightbox_secret => "12345",
|
328
|
+
:brightbox_temp_url_key => temp_url_key
|
329
|
+
}
|
330
|
+
end
|
331
|
+
let(:container) { "container" }
|
332
|
+
let(:object) { "file.ext" }
|
333
|
+
let(:expiry_time) { Time.utc(2012) }
|
334
|
+
let(:request_method) { "GET" }
|
335
|
+
|
336
|
+
it "raises an error" do
|
337
|
+
assert_raises Fog::Brightbox::Storage::ManagementUrlUnknown do
|
338
|
+
service.create_temp_url(container, object, expiry_time, request_method, :scheme => "https")
|
339
|
+
end
|
340
|
+
end
|
341
|
+
end
|
320
342
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fog-brightbox
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.15.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Paul Thornthwaite
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2018-06-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: fog-core
|
@@ -52,6 +52,20 @@ dependencies:
|
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: 0.0.2
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: mime-types
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
55
69
|
- !ruby/object:Gem::Dependency
|
56
70
|
name: bundler
|
57
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -460,7 +474,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
460
474
|
version: '0'
|
461
475
|
requirements: []
|
462
476
|
rubyforge_project:
|
463
|
-
rubygems_version: 2.6
|
477
|
+
rubygems_version: 2.7.6
|
464
478
|
signing_key:
|
465
479
|
specification_version: 4
|
466
480
|
summary: This library can be used as a module for `fog` or as standalone provider
|