api-auth 1.3.1 → 1.3.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/Gemfile.lock +1 -1
- data/README.md +9 -0
- data/VERSION +1 -1
- data/gemfiles/rails_23.gemfile.lock +1 -1
- data/gemfiles/rails_30.gemfile.lock +1 -1
- data/gemfiles/rails_31.gemfile.lock +1 -1
- data/gemfiles/rails_32.gemfile.lock +1 -1
- data/gemfiles/rails_4.gemfile.lock +1 -1
- data/gemfiles/rails_41.gemfile.lock +1 -1
- data/lib/api_auth/headers.rb +8 -2
- data/spec/headers_spec.rb +37 -1
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2cd28f63f509490e9930a666f6825bbfd58b2bb7
|
4
|
+
data.tar.gz: 0c5c85110090293af02dd2c2d2ded29ebf2c1589
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7bdd120e4c0e769a1ac1e67051f5e69675204e4f511eaece5cb0f967604cf2c2fbea3f44d80b7f8b947fa82e7888b0938e98517be0a3267fab11064de1f782c1
|
7
|
+
data.tar.gz: f12c425faa929ed3aa9ca0fabbcd44d89e4fdd42f65a974df2a35c112a9503b5279a9965c30a6c679d5973a6e43fd47e7717ea66c803733241c1baa29f50f408
|
data/CHANGELOG.md
CHANGED
data/Gemfile.lock
CHANGED
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.3.2
|
data/lib/api_auth/headers.rb
CHANGED
@@ -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
|
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
|
-
|
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
|
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.
|
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-
|
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.
|
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:
|