swift-storage 0.0.3 → 0.0.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/lib/swift_storage/service.rb +16 -1
- data/lib/swift_storage/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c4b1ed3fd7ef8147daf7ec86b0bcc96d5df8f413
|
4
|
+
data.tar.gz: e5260ac7a3f35f3ae8b23fd8925421bcbdfdd0e8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7ec74589deb905d2f98cd3543b9ac180434221df2df2546ccf86d619638afb370982c72c259501aca8b0a6c8c6abce4495e74652e287d3de3b9a451c27aeaa48
|
7
|
+
data.tar.gz: 6cd044e4f569f9f22926e2bfeb0d54024191023cf5d70987114f8ac4b04eeb3edfd985b66a712346c17027c573df01ebdfcc5eac5f3c84fc9825b37dd7afab72
|
@@ -9,6 +9,7 @@ class SwiftStorage::Service
|
|
9
9
|
:endpoint,
|
10
10
|
:storage_url,
|
11
11
|
:auth_token,
|
12
|
+
:auth_at,
|
12
13
|
:storage_token,
|
13
14
|
:storage_scheme,
|
14
15
|
:storage_host,
|
@@ -33,6 +34,9 @@ class SwiftStorage::Service
|
|
33
34
|
end
|
34
35
|
|
35
36
|
def authenticate!
|
37
|
+
@auth_token = nil
|
38
|
+
@storage_token = nil
|
39
|
+
@auth_at = nil
|
36
40
|
headers = {
|
37
41
|
Headers::AUTH_USER => "#{tenant}:#{username}",
|
38
42
|
Headers::AUTH_KEY => password
|
@@ -43,6 +47,7 @@ class SwiftStorage::Service
|
|
43
47
|
self.storage_url = h[Headers::STORAGE_URL]
|
44
48
|
@auth_token = h[Headers::AUTH_TOKEN]
|
45
49
|
@storage_token = h[Headers::STORAGE_TOKEN]
|
50
|
+
@auth_at = Time.new
|
46
51
|
end
|
47
52
|
|
48
53
|
def authenticated?
|
@@ -175,7 +180,17 @@ class SwiftStorage::Service
|
|
175
180
|
end
|
176
181
|
|
177
182
|
response = s.request(req, &output_proc)
|
178
|
-
|
183
|
+
begin
|
184
|
+
check_response!(response)
|
185
|
+
rescue AuthError
|
186
|
+
# If token is at least 60 second old, we try to get a new one
|
187
|
+
if @auth_at && (Time.now - @auth_at).to_i > 60
|
188
|
+
authenticate!
|
189
|
+
response = s.request(req, &output_proc)
|
190
|
+
else
|
191
|
+
raise
|
192
|
+
end
|
193
|
+
end
|
179
194
|
response
|
180
195
|
end
|
181
196
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: swift-storage
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nicolas Goy
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2015-01-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|