api-auth 1.3.1 → 1.3.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8df4c4b6537d3646e5159fb10b1ff7839455cd96
4
- data.tar.gz: c50289d2bca57c241f41bbdbf5c9a268505c18ab
3
+ metadata.gz: 2cd28f63f509490e9930a666f6825bbfd58b2bb7
4
+ data.tar.gz: 0c5c85110090293af02dd2c2d2ded29ebf2c1589
5
5
  SHA512:
6
- metadata.gz: 2d11fd71f2ec739b442c1e87c350cc4ec09dd5f1c5acff642abed86a5162654da541eb73d6a3f2146cea3dd07b265741e778e5cdf48da472e00b5404fa1ef07e
7
- data.tar.gz: 27cc78257708f8f96f95cf4ef1ceb3070c37b30330a1ba8c22278c0891601166345d3a803add2762f9b8bb6dee2d46aa7bdf87f923c4a59943fba3ddb9c95694
6
+ metadata.gz: 7bdd120e4c0e769a1ac1e67051f5e69675204e4f511eaece5cb0f967604cf2c2fbea3f44d80b7f8b947fa82e7888b0938e98517be0a3267fab11064de1f782c1
7
+ data.tar.gz: f12c425faa929ed3aa9ca0fabbcd44d89e4fdd42f65a974df2a35c112a9503b5279a9965c30a6c679d5973a6e43fd47e7717ea66c803733241c1baa29f50f408
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ # 1.3.2 (2015-08-28)
2
+ - Fixed a bug where some client adapters didn't treat an empty path as
3
+ "/" in the canonical string (#75 managr)
4
+
1
5
  # 1.3.1 (2015-03-13)
2
6
  - Fixed a bug where Faraday requests with no parameters were not signed
3
7
  correctly (#65 nathanhoel)
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- api-auth (1.3.1)
4
+ api-auth (1.3.2)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
data/README.md CHANGED
@@ -120,6 +120,15 @@ single configuration line:
120
120
 
121
121
  This will automatically sign all outgoing ActiveResource requests from your app.
122
122
 
123
+ ### Active Rest Client
124
+
125
+ ApiAuth also works with [ActiveRestClient](https://github.com/whichdigital/active-rest-client) in a very similar way.
126
+ Simply add this configuration to your ActiveRestClient initializer in your app and it will automatically sign all outgoing requests.
127
+
128
+ ``` ruby
129
+ ActiveRestClient::Base.api_auth_credentials(@access_id, @secret_key)
130
+ ```
131
+
123
132
  ## Server
124
133
 
125
134
  ApiAuth provides some built in methods to help you generate API keys for your
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.3.1
1
+ 1.3.2
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: ../
3
3
  specs:
4
- api-auth (1.3.1)
4
+ api-auth (1.3.2)
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.3.1)
4
+ api-auth (1.3.2)
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.3.1)
4
+ api-auth (1.3.2)
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.3.1)
4
+ api-auth (1.3.2)
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.3.1)
4
+ api-auth (1.3.2)
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.3.1)
4
+ api-auth (1.3.2)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -55,7 +55,7 @@ module ApiAuth
55
55
  def canonical_string
56
56
  [ @request.content_type,
57
57
  @request.content_md5,
58
- @request.request_uri.gsub(/https?:\/\/[^(,|\?|\/)]*/,''), # remove host
58
+ parse_uri(@request.request_uri),
59
59
  @request.timestamp
60
60
  ].join(",")
61
61
  end
@@ -90,6 +90,12 @@ module ApiAuth
90
90
  @request.set_auth_header header
91
91
  end
92
92
 
93
- end
93
+ private
94
94
 
95
+ def parse_uri(uri)
96
+ uri_without_host = uri.gsub(/https?:\/\/[^(,|\?|\/)]*/, '')
97
+ return '/' if uri_without_host.empty?
98
+ uri_without_host
99
+ end
100
+ end
95
101
  end
data/spec/headers_spec.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
2
 
3
- describe "ApiAuth::Headers" do
3
+ describe ApiAuth::Headers do
4
4
 
5
5
  CANONICAL_STRING = "text/plain,e59ff97941044f85df5297e1c302d260,/resource.xml?foo=bar&bar=foo,Mon, 23 Jan 1984 03:29:56 GMT"
6
6
 
@@ -300,4 +300,40 @@ describe "ApiAuth::Headers" do
300
300
  end
301
301
  end
302
302
 
303
+ describe '#canonical_string' do
304
+ let(:request) { RestClient::Request.new(:url => uri, :method => :get) }
305
+ subject { described_class.new(request) }
306
+
307
+ context 'empty uri' do
308
+ let(:uri) { ''.freeze }
309
+
310
+ it 'adds / to canonical string' do
311
+ subject.canonical_string.should eq(',,/,')
312
+ end
313
+ end
314
+
315
+ context 'uri with just host without /' do
316
+ let(:uri) { 'http://google.com'.freeze }
317
+
318
+ it 'return / as canonical string path' do
319
+ subject.canonical_string.should eq(',,/,')
320
+ end
321
+
322
+ it 'does not change request url (by removing host)' do
323
+ request.url.should eq(uri)
324
+ end
325
+ end
326
+
327
+ context 'uri with host and /' do
328
+ let(:uri) { 'http://google.com/'.freeze }
329
+
330
+ it 'return / as canonical string path' do
331
+ subject.canonical_string.should eq(',,/,')
332
+ end
333
+
334
+ it 'does not change request url (by removing host)' do
335
+ request.url.should eq(uri)
336
+ end
337
+ end
338
+ end
303
339
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: api-auth
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.1
4
+ version: 1.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mauricio Gomes
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-03-13 00:00:00.000000000 Z
11
+ date: 2015-08-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: appraisal
@@ -251,7 +251,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
251
251
  version: '0'
252
252
  requirements: []
253
253
  rubyforge_project:
254
- rubygems_version: 2.2.2
254
+ rubygems_version: 2.4.8
255
255
  signing_key:
256
256
  specification_version: 4
257
257
  summary: Simple HMAC authentication for your APIs
@@ -264,3 +264,4 @@ test_files:
264
264
  - spec/railtie_spec.rb
265
265
  - spec/spec_helper.rb
266
266
  - spec/test_helper.rb
267
+ has_rdoc: