api-auth 1.0.2 → 1.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +1 -1
- data/Gemfile.lock +2 -2
- data/VERSION +1 -1
- data/lib/api_auth/headers.rb +1 -1
- data/lib/api_auth/railtie.rb +2 -0
- data/lib/api_auth/request_drivers/action_controller.rb +1 -1
- data/lib/api_auth/request_drivers/rest_client.rb +9 -1
- data/spec/api_auth_spec.rb +1 -1
- data/spec/headers_spec.rb +1 -1
- metadata +4 -4
data/Gemfile
CHANGED
@@ -1,2 +1,2 @@
|
|
1
|
-
source
|
1
|
+
source 'https://rubygems.org'
|
2
2
|
gemspec
|
data/Gemfile.lock
CHANGED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.0.
|
1
|
+
1.0.3
|
data/lib/api_auth/headers.rb
CHANGED
data/lib/api_auth/railtie.rb
CHANGED
@@ -95,7 +95,9 @@ module ApiAuth
|
|
95
95
|
if use_hmac && hmac_access_id && hmac_secret_key
|
96
96
|
h = arguments.last
|
97
97
|
tmp = "Net::HTTP::#{method.to_s.capitalize}".constantize.new(path, h)
|
98
|
+
tmp.body = arguments[0] if arguments.length > 1
|
98
99
|
ApiAuth.sign!(tmp, hmac_access_id, hmac_secret_key)
|
100
|
+
arguments.last['Content-MD5'] = tmp['Content-MD5'] if tmp['Content-MD5']
|
99
101
|
arguments.last['DATE'] = tmp['DATE']
|
100
102
|
arguments.last['Authorization'] = tmp['Authorization']
|
101
103
|
end
|
@@ -1,3 +1,6 @@
|
|
1
|
+
# give access to RestClient @processed_headers
|
2
|
+
module RestClient;class Request;attr_accessor :processed_headers;end;end
|
3
|
+
|
1
4
|
module ApiAuth
|
2
5
|
|
3
6
|
module RequestDrivers # :nodoc:
|
@@ -15,6 +18,7 @@ module ApiAuth
|
|
15
18
|
def set_auth_header(header)
|
16
19
|
@request.headers.merge!({ "Authorization" => header })
|
17
20
|
@headers = fetch_headers
|
21
|
+
save_headers # enforce update of processed_headers based on last updated headers
|
18
22
|
@request
|
19
23
|
end
|
20
24
|
|
@@ -77,7 +81,11 @@ module ApiAuth
|
|
77
81
|
def find_header(keys)
|
78
82
|
keys.map {|key| @headers[key] }.compact.first
|
79
83
|
end
|
80
|
-
|
84
|
+
|
85
|
+
def save_headers
|
86
|
+
@request.processed_headers = @request.make_headers(@headers)
|
87
|
+
end
|
88
|
+
|
81
89
|
end
|
82
90
|
|
83
91
|
end
|
data/spec/api_auth_spec.rb
CHANGED
@@ -280,7 +280,7 @@ describe "ApiAuth" do
|
|
280
280
|
'REQUEST_METHOD' => 'PUT',
|
281
281
|
'CONTENT_TYPE' => 'text/plain',
|
282
282
|
'HTTP_DATE' => 'Mon, 23 Jan 1984 03:29:56 GMT',
|
283
|
-
'
|
283
|
+
'RAW_POST_DATA' => "hello\nworld")
|
284
284
|
signed_request = ApiAuth.sign!(request, @access_id, @secret_key)
|
285
285
|
signed_request.env['Content-MD5'].should == Digest::MD5.base64digest("hello\nworld")
|
286
286
|
end
|
data/spec/headers_spec.rb
CHANGED
@@ -194,7 +194,7 @@ describe "ApiAuth::Headers" do
|
|
194
194
|
end
|
195
195
|
|
196
196
|
it "should generate the proper canonical string" do
|
197
|
-
@headers.canonical_string.should ==
|
197
|
+
@headers.canonical_string.should == CANONICAL_STRING
|
198
198
|
end
|
199
199
|
|
200
200
|
it "should set the authorization header" do
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: api-auth
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-
|
12
|
+
date: 2013-04-04 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rake
|
@@ -189,7 +189,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
189
189
|
version: '0'
|
190
190
|
segments:
|
191
191
|
- 0
|
192
|
-
hash:
|
192
|
+
hash: 579957539921083557
|
193
193
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
194
194
|
none: false
|
195
195
|
requirements:
|
@@ -198,7 +198,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
198
198
|
version: '0'
|
199
199
|
segments:
|
200
200
|
- 0
|
201
|
-
hash:
|
201
|
+
hash: 579957539921083557
|
202
202
|
requirements: []
|
203
203
|
rubyforge_project:
|
204
204
|
rubygems_version: 1.8.24
|