api-auth 1.2.0 → 1.2.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: e56cb7a8470464f1c066a02ad4caeb9864c612cb
4
+ data.tar.gz: b343e1646d443bed40bb7513efd85f76cb806297
5
+ SHA512:
6
+ metadata.gz: b04802be5d905287f2948f8a3b1b712faf77ac722e479f3e20088279797e0f70589b822883c36749d54c590ff1a3f936d96c7dbed880f21e07063440ed8d9b1d
7
+ data.tar.gz: 27709d13a88f750aecd9495a4d617d1608d1c751ef41fbe69d2c9f950d54a4f7041920d7c6724d1b3698b172fd2d2852541e886a07732be965426aec7b0cc664
@@ -8,10 +8,13 @@ gemfile:
8
8
  - gemfiles/rails_31.gemfile
9
9
  - gemfiles/rails_32.gemfile
10
10
  - gemfiles/rails_4.gemfile
11
+ - gemfiles/rails_41.gemfile
11
12
  matrix:
12
13
  exclude:
13
14
  - rvm: 1.8.7-p374
14
15
  gemfile: gemfiles/rails_4.gemfile
16
+ - rvm: 1.8.7-p374
17
+ gemfile: gemfiles/rails_41.gemfile
15
18
 
16
19
  notifications:
17
20
  email: false
data/Appraisals CHANGED
@@ -1,3 +1,9 @@
1
+ appraise "rails-41" do
2
+ gem "actionpack", "~> 4.1.0"
3
+ gem "activeresource", "~> 4.0.0"
4
+ gem "activesupport", "~> 4.1.0"
5
+ end
6
+
1
7
  appraise "rails-4" do
2
8
  gem "actionpack", "~> 4.0.4"
3
9
  gem "activeresource", "~> 4.0.0"
@@ -1,3 +1,9 @@
1
+ # 1.2.1 (2014-07-03)
2
+
3
+ - Fix Rest Client driver to account for the generated md5 when signing (#45 cjeeky)
4
+ - Support for testing against Rails 4.1 (#42 awendt)
5
+ - Support all requests inheriting from Rack::Request (#43 mcls)
6
+
1
7
  # 1.2.0 (2014-05-16)
2
8
 
3
9
  - Fix ruby 1.8.7 support
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- api-auth (1.1.0)
4
+ api-auth (1.2.1)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.2.0
1
+ 1.2.1
@@ -1,7 +1,9 @@
1
+ # This file was generated by Appraisal
2
+
1
3
  source "https://rubygems.org"
2
4
 
3
5
  gem "actionpack", "~> 2.3.2"
4
6
  gem "activeresource", "~> 2.3.2"
5
7
  gem "activesupport", "~> 2.3.2"
6
8
 
7
- gemspec :path=>"../"
9
+ gemspec :path=>"../"
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: ../
3
3
  specs:
4
- api-auth (1.1.0)
4
+ api-auth (1.2.1)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -1,7 +1,9 @@
1
+ # This file was generated by Appraisal
2
+
1
3
  source "https://rubygems.org"
2
4
 
3
5
  gem "actionpack", "~> 3.0.20"
4
6
  gem "activeresource", "~> 3.0.20"
5
7
  gem "activesupport", "~> 3.0.20"
6
8
 
7
- gemspec :path=>"../"
9
+ gemspec :path=>"../"
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: ../
3
3
  specs:
4
- api-auth (1.1.0)
4
+ api-auth (1.2.1)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: ../
3
3
  specs:
4
- api-auth (1.1.0)
4
+ api-auth (1.2.1)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: ../
3
3
  specs:
4
- api-auth (1.1.0)
4
+ api-auth (1.2.1)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: ../
3
3
  specs:
4
- api-auth (1.1.0)
4
+ api-auth (1.2.1)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -0,0 +1,9 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "actionpack", "~> 4.1.0"
6
+ gem "activeresource", "~> 4.0.0"
7
+ gem "activesupport", "~> 4.1.0"
8
+
9
+ gemspec :path=>"../"
@@ -0,0 +1,85 @@
1
+ PATH
2
+ remote: ../
3
+ specs:
4
+ api-auth (1.2.1)
5
+
6
+ GEM
7
+ remote: https://rubygems.org/
8
+ specs:
9
+ actionpack (4.1.1)
10
+ actionview (= 4.1.1)
11
+ activesupport (= 4.1.1)
12
+ rack (~> 1.5.2)
13
+ rack-test (~> 0.6.2)
14
+ actionview (4.1.1)
15
+ activesupport (= 4.1.1)
16
+ builder (~> 3.1)
17
+ erubis (~> 2.7.0)
18
+ activemodel (4.1.1)
19
+ activesupport (= 4.1.1)
20
+ builder (~> 3.1)
21
+ activeresource (4.0.0)
22
+ activemodel (~> 4.0)
23
+ activesupport (~> 4.0)
24
+ rails-observers (~> 0.1.1)
25
+ activesupport (4.1.1)
26
+ i18n (~> 0.6, >= 0.6.9)
27
+ json (~> 1.7, >= 1.7.7)
28
+ minitest (~> 5.1)
29
+ thread_safe (~> 0.1)
30
+ tzinfo (~> 1.1)
31
+ amatch (0.3.0)
32
+ tins (~> 1.0)
33
+ appraisal (1.0.0)
34
+ bundler
35
+ rake
36
+ thor (>= 0.14.0)
37
+ builder (3.2.2)
38
+ curb (0.8.5)
39
+ diff-lcs (1.1.3)
40
+ erubis (2.7.0)
41
+ httpi (2.1.0)
42
+ rack
43
+ rubyntlm (~> 0.3.2)
44
+ i18n (0.6.9)
45
+ json (1.8.1)
46
+ mime-types (2.2)
47
+ minitest (5.3.4)
48
+ rack (1.5.2)
49
+ rack-test (0.6.2)
50
+ rack (>= 1.0)
51
+ rails-observers (0.1.2)
52
+ activemodel (~> 4.0)
53
+ rake (10.3.2)
54
+ rest-client (1.6.7)
55
+ mime-types (>= 1.16)
56
+ rspec (2.4.0)
57
+ rspec-core (~> 2.4.0)
58
+ rspec-expectations (~> 2.4.0)
59
+ rspec-mocks (~> 2.4.0)
60
+ rspec-core (2.4.0)
61
+ rspec-expectations (2.4.0)
62
+ diff-lcs (~> 1.1.2)
63
+ rspec-mocks (2.4.0)
64
+ rubyntlm (0.3.4)
65
+ thor (0.19.1)
66
+ thread_safe (0.3.3)
67
+ tins (1.3.0)
68
+ tzinfo (1.1.0)
69
+ thread_safe (~> 0.1)
70
+
71
+ PLATFORMS
72
+ ruby
73
+
74
+ DEPENDENCIES
75
+ actionpack (~> 4.1.0)
76
+ activeresource (~> 4.0.0)
77
+ activesupport (~> 4.1.0)
78
+ amatch
79
+ api-auth!
80
+ appraisal
81
+ curb (~> 0.8.1)
82
+ httpi
83
+ rake
84
+ rest-client (~> 1.6.0)
85
+ rspec (~> 2.4.0)
@@ -7,37 +7,42 @@ module ApiAuth
7
7
 
8
8
  def initialize(request)
9
9
  @original_request = request
10
+ @request = initialize_request_driver(request)
11
+ true
12
+ end
10
13
 
11
- case request.class.to_s
12
- when /Net::HTTP/
13
- @request = NetHttpRequest.new(request)
14
- when /RestClient/
15
- @request = RestClientRequest.new(request)
16
- when /Curl::Easy/
17
- @request = CurbRequest.new(request)
18
- when /ActionController::Request/
19
- @request = ActionControllerRequest.new(request)
20
- when /ActionController::TestRequest/
21
- if defined?(ActionDispatch)
22
- @request = ActionDispatchRequest.new(request)
14
+ def initialize_request_driver(request)
15
+ new_request =
16
+ case request.class.to_s
17
+ when /Net::HTTP/
18
+ NetHttpRequest.new(request)
19
+ when /RestClient/
20
+ RestClientRequest.new(request)
21
+ when /Curl::Easy/
22
+ CurbRequest.new(request)
23
+ when /ActionController::Request/
24
+ ActionControllerRequest.new(request)
25
+ when /ActionController::TestRequest/
26
+ if defined?(ActionDispatch)
27
+ ActionDispatchRequest.new(request)
28
+ else
29
+ ActionControllerRequest.new(request)
30
+ end
31
+ when /ActionDispatch::Request/
32
+ ActionDispatchRequest.new(request)
33
+ when /ActionController::CgiRequest/
34
+ ActionControllerRequest.new(request)
35
+ when /HTTPI::Request/
36
+ HttpiRequest.new(request)
23
37
  else
24
- @request = ActionControllerRequest.new(request)
38
+ nil
25
39
  end
26
- when /ActionDispatch::Request/
27
- @request = ActionDispatchRequest.new(request)
28
- when /Rack::Request/
29
- @request = RackRequest.new(request)
30
- when /ActionController::CgiRequest/
31
- @request = ActionControllerRequest.new(request)
32
- when /HTTPI::Request/
33
- @request = HttpiRequest.new(request)
34
- when /Sinatra::Request/
35
- @request = RackRequest.new(request)
36
- else
37
- raise UnknownHTTPRequest, "#{request.class.to_s} is not yet supported."
38
- end
39
- true
40
+
41
+ return new_request if new_request
42
+ return RackRequest.new(request) if request.kind_of?(Rack::Request)
43
+ raise UnknownHTTPRequest, "#{request.class.to_s} is not yet supported."
40
44
  end
45
+ private :initialize_request_driver
41
46
 
42
47
  # Returns the request timestamp
43
48
  def timestamp
@@ -34,6 +34,7 @@ module ApiAuth
34
34
  def populate_content_md5
35
35
  if [:post, :put].include?(@request.method)
36
36
  @request.headers["Content-MD5"] = calculated_md5
37
+ save_headers
37
38
  end
38
39
  end
39
40
 
@@ -155,6 +155,26 @@ describe "ApiAuth" do
155
155
  @signed_request.headers['Authorization'].should == "APIAuth 1044:#{hmac(@secret_key, @request)}"
156
156
  end
157
157
 
158
+ it "should sign the request using the generated md5 header" do
159
+ date = Time.now.utc.httpdate
160
+ headers1 = { 'Content-MD5' => "1B2M2Y8AsgTpgAmY7PhCfg==",
161
+ 'Content-Type' => "text/plain",
162
+ 'Date' => date }
163
+ request1 = RestClient::Request.new(:url => "/resource.xml?foo=bar&bar=foo",
164
+ :headers => headers1,
165
+ :method => :put)
166
+ headers2 = { 'Content-Type' => "text/plain",
167
+ 'Date' => date }
168
+ request2 = RestClient::Request.new(:url => "/resource.xml?foo=bar&bar=foo",
169
+ :headers => headers2,
170
+ :method => :put)
171
+
172
+ ApiAuth.sign!(request1, @access_id, @secret_key)
173
+ ApiAuth.sign!(request2, @access_id, @secret_key)
174
+
175
+ request2.headers['Authorization'].should == request1.headers['Authorization']
176
+ end
177
+
158
178
  it "should authenticate a valid request" do
159
179
  ApiAuth.authentic?(@signed_request, @secret_key).should be_true
160
180
  end
metadata CHANGED
@@ -1,68 +1,60 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: api-auth
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.0
5
- prerelease:
4
+ version: 1.2.1
6
5
  platform: ruby
7
6
  authors:
8
7
  - Mauricio Gomes
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2014-05-16 00:00:00.000000000 Z
11
+ date: 2014-07-03 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: appraisal
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
- - - ! '>='
17
+ - - '>='
20
18
  - !ruby/object:Gem::Version
21
19
  version: '0'
22
20
  type: :development
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
- - - ! '>='
24
+ - - '>='
28
25
  - !ruby/object:Gem::Version
29
26
  version: '0'
30
27
  - !ruby/object:Gem::Dependency
31
28
  name: rake
32
29
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
30
  requirements:
35
- - - ! '>='
31
+ - - '>='
36
32
  - !ruby/object:Gem::Version
37
33
  version: '0'
38
34
  type: :development
39
35
  prerelease: false
40
36
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
37
  requirements:
43
- - - ! '>='
38
+ - - '>='
44
39
  - !ruby/object:Gem::Version
45
40
  version: '0'
46
41
  - !ruby/object:Gem::Dependency
47
42
  name: amatch
48
43
  requirement: !ruby/object:Gem::Requirement
49
- none: false
50
44
  requirements:
51
- - - ! '>='
45
+ - - '>='
52
46
  - !ruby/object:Gem::Version
53
47
  version: '0'
54
48
  type: :development
55
49
  prerelease: false
56
50
  version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
51
  requirements:
59
- - - ! '>='
52
+ - - '>='
60
53
  - !ruby/object:Gem::Version
61
54
  version: '0'
62
55
  - !ruby/object:Gem::Dependency
63
56
  name: rspec
64
57
  requirement: !ruby/object:Gem::Requirement
65
- none: false
66
58
  requirements:
67
59
  - - ~>
68
60
  - !ruby/object:Gem::Version
@@ -70,7 +62,6 @@ dependencies:
70
62
  type: :development
71
63
  prerelease: false
72
64
  version_requirements: !ruby/object:Gem::Requirement
73
- none: false
74
65
  requirements:
75
66
  - - ~>
76
67
  - !ruby/object:Gem::Version
@@ -78,7 +69,6 @@ dependencies:
78
69
  - !ruby/object:Gem::Dependency
79
70
  name: actionpack
80
71
  requirement: !ruby/object:Gem::Requirement
81
- none: false
82
72
  requirements:
83
73
  - - ~>
84
74
  - !ruby/object:Gem::Version
@@ -86,7 +76,6 @@ dependencies:
86
76
  type: :development
87
77
  prerelease: false
88
78
  version_requirements: !ruby/object:Gem::Requirement
89
- none: false
90
79
  requirements:
91
80
  - - ~>
92
81
  - !ruby/object:Gem::Version
@@ -94,7 +83,6 @@ dependencies:
94
83
  - !ruby/object:Gem::Dependency
95
84
  name: activesupport
96
85
  requirement: !ruby/object:Gem::Requirement
97
- none: false
98
86
  requirements:
99
87
  - - ~>
100
88
  - !ruby/object:Gem::Version
@@ -102,7 +90,6 @@ dependencies:
102
90
  type: :development
103
91
  prerelease: false
104
92
  version_requirements: !ruby/object:Gem::Requirement
105
- none: false
106
93
  requirements:
107
94
  - - ~>
108
95
  - !ruby/object:Gem::Version
@@ -110,7 +97,6 @@ dependencies:
110
97
  - !ruby/object:Gem::Dependency
111
98
  name: activeresource
112
99
  requirement: !ruby/object:Gem::Requirement
113
- none: false
114
100
  requirements:
115
101
  - - ~>
116
102
  - !ruby/object:Gem::Version
@@ -118,7 +104,6 @@ dependencies:
118
104
  type: :development
119
105
  prerelease: false
120
106
  version_requirements: !ruby/object:Gem::Requirement
121
- none: false
122
107
  requirements:
123
108
  - - ~>
124
109
  - !ruby/object:Gem::Version
@@ -126,7 +111,6 @@ dependencies:
126
111
  - !ruby/object:Gem::Dependency
127
112
  name: rest-client
128
113
  requirement: !ruby/object:Gem::Requirement
129
- none: false
130
114
  requirements:
131
115
  - - ~>
132
116
  - !ruby/object:Gem::Version
@@ -134,7 +118,6 @@ dependencies:
134
118
  type: :development
135
119
  prerelease: false
136
120
  version_requirements: !ruby/object:Gem::Requirement
137
- none: false
138
121
  requirements:
139
122
  - - ~>
140
123
  - !ruby/object:Gem::Version
@@ -142,7 +125,6 @@ dependencies:
142
125
  - !ruby/object:Gem::Dependency
143
126
  name: curb
144
127
  requirement: !ruby/object:Gem::Requirement
145
- none: false
146
128
  requirements:
147
129
  - - ~>
148
130
  - !ruby/object:Gem::Version
@@ -150,7 +132,6 @@ dependencies:
150
132
  type: :development
151
133
  prerelease: false
152
134
  version_requirements: !ruby/object:Gem::Requirement
153
- none: false
154
135
  requirements:
155
136
  - - ~>
156
137
  - !ruby/object:Gem::Version
@@ -158,17 +139,15 @@ dependencies:
158
139
  - !ruby/object:Gem::Dependency
159
140
  name: httpi
160
141
  requirement: !ruby/object:Gem::Requirement
161
- none: false
162
142
  requirements:
163
- - - ! '>='
143
+ - - '>='
164
144
  - !ruby/object:Gem::Version
165
145
  version: '0'
166
146
  type: :development
167
147
  prerelease: false
168
148
  version_requirements: !ruby/object:Gem::Requirement
169
- none: false
170
149
  requirements:
171
- - - ! '>='
150
+ - - '>='
172
151
  - !ruby/object:Gem::Version
173
152
  version: '0'
174
153
  description: Full HMAC auth implementation for use in your gems and Rails apps.
@@ -200,6 +179,8 @@ files:
200
179
  - gemfiles/rails_32.gemfile.lock
201
180
  - gemfiles/rails_4.gemfile
202
181
  - gemfiles/rails_4.gemfile.lock
182
+ - gemfiles/rails_41.gemfile
183
+ - gemfiles/rails_41.gemfile.lock
203
184
  - lib/api-auth.rb
204
185
  - lib/api_auth.rb
205
186
  - lib/api_auth/base.rb
@@ -223,27 +204,26 @@ files:
223
204
  - spec/test_helper.rb
224
205
  homepage: https://github.com/mgomes/api_auth
225
206
  licenses: []
207
+ metadata: {}
226
208
  post_install_message:
227
209
  rdoc_options: []
228
210
  require_paths:
229
211
  - lib
230
212
  required_ruby_version: !ruby/object:Gem::Requirement
231
- none: false
232
213
  requirements:
233
- - - ! '>='
214
+ - - '>='
234
215
  - !ruby/object:Gem::Version
235
216
  version: '0'
236
217
  required_rubygems_version: !ruby/object:Gem::Requirement
237
- none: false
238
218
  requirements:
239
- - - ! '>='
219
+ - - '>='
240
220
  - !ruby/object:Gem::Version
241
221
  version: '0'
242
222
  requirements: []
243
223
  rubyforge_project:
244
- rubygems_version: 1.8.23.2
224
+ rubygems_version: 2.0.14
245
225
  signing_key:
246
- specification_version: 3
226
+ specification_version: 4
247
227
  summary: Simple HMAC authentication for your APIs
248
228
  test_files:
249
229
  - spec/api_auth_spec.rb