ey_api_hmac 0.3.0 → 0.3.1

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -30,3 +30,33 @@ Rack-Client middleware:
30
30
  ```
31
31
 
32
32
  this will add the correct Authorization header to all requests made with this rack-client.
33
+
34
+ # Imlementation details:
35
+
36
+ before signed:
37
+
38
+ {"REQUEST_URI"=>"http://example.com/api/1/service_accounts/1324/messages", "PATH_INFO"=>"/api/1/service_accounts/1324/messages", "CONTENT_TYPE"=>"application/json", "HTTP_ACCEPT"=>"application/json", "REQUEST_METHOD"=>"POST", "HTTP_DATE"=>"Thu, 15 Dec 2011 23:50:33 GMT", "rack.input"=>#<StringIO:0x007fd9239f6998>}
39
+
40
+ request body:
41
+
42
+ {"message":{"message_type":"status","subject":"Everything looks good.","body":null}}
43
+
44
+ auth_id:
45
+
46
+ 123bc211233eabc
47
+
48
+ auth_key:
49
+
50
+ abc474e3fc9bddf6d41236b70cc5a952f3681166e1239214740d13eecd12318f7b8d27123b61eabc
51
+
52
+ canonical_string:
53
+
54
+ "POST\napplication/json\ne8fa80541e3726e2cf4c71d07a7bd9fd\nThu, 15 Dec 2011 23:50:33 GMT\n/api/1/service_accounts/1324/messages"
55
+
56
+ signature:
57
+
58
+ UZDkXszu4dp6Gz2TEGcy/cVt0R0=
59
+
60
+ now signed:
61
+
62
+ {"REQUEST_URI"=>"http://example.com/api/1/service_accounts/1324/messages", "PATH_INFO"=>"/api/1/service_accounts/1324/messages", "CONTENT_TYPE"=>"application/json", "HTTP_ACCEPT"=>"application/json", "REQUEST_METHOD"=>"POST", "HTTP_DATE"=>"Thu, 15 Dec 2011 23:50:33 GMT", "rack.input"=>#<StringIO:0x007fd9239f6998>, "HTTP_AUTHORIZATION"=>"AuthHMAC 123bc211233eabc:UZDkXszu4dp6Gz2TEGcy/cVt0R0="}
@@ -1,5 +1,5 @@
1
1
  module EY
2
2
  module ApiHMAC
3
- VERSION = "0.3.0"
3
+ VERSION = "0.3.1"
4
4
  end
5
5
  end
data/lib/ey_api_hmac.rb CHANGED
@@ -25,7 +25,7 @@ module EY
25
25
  if env["REQUEST_URI"]
26
26
  parts << URI.parse(env["REQUEST_URI"]).path
27
27
  else
28
- parts << expect["PATH_INFO"]
28
+ parts << (env["SCRIPT_NAME"] + expect["PATH_INFO"])
29
29
  end
30
30
  parts.join("\n")
31
31
  end
@@ -73,6 +73,14 @@ describe EY::ApiHMAC::ApiAuth do
73
73
  AuthHMAC.canonical_string(@request).should == expected
74
74
  EY::ApiHMAC.canonical_string(@env).should == expected
75
75
  end
76
+ it "should generate a canonical string with SCRIPT_NAME" do
77
+ env = @env.merge("SCRIPT_NAME" => "/api")
78
+ env.delete("REQUEST_URI")
79
+ expected = "PUT\ntext/plain\n78b9d09661da64f0bc6c146c524bae4a\nThu, 10 Jul 2008 03:29:56 GMT\n/api/path/to/put"
80
+ request = Rack::Request.new(env)
81
+ AuthHMAC.canonical_string(request).should == expected
82
+ EY::ApiHMAC.canonical_string(env).should == expected
83
+ end
76
84
  end
77
85
 
78
86
  describe ".signature" do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ey_api_hmac
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.3.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-12-15 00:00:00.000000000 Z
12
+ date: 2011-12-16 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rack-client
16
- requirement: &70125212725320 !ruby/object:Gem::Requirement
16
+ requirement: &2161109420 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70125212725320
24
+ version_requirements: *2161109420
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: json
27
- requirement: &70125212724900 !ruby/object:Gem::Requirement
27
+ requirement: &2161108660 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: '0'
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *70125212724900
35
+ version_requirements: *2161108660
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: rspec
38
- requirement: &70125212724480 !ruby/object:Gem::Requirement
38
+ requirement: &2161107340 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,7 +43,7 @@ dependencies:
43
43
  version: '0'
44
44
  type: :development
45
45
  prerelease: false
46
- version_requirements: *70125212724480
46
+ version_requirements: *2161107340
47
47
  description: basic wrapper for rack-client + middlewares for HMAC auth + helpers for
48
48
  SSO auth
49
49
  email:
@@ -90,7 +90,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
90
90
  version: '0'
91
91
  requirements: []
92
92
  rubyforge_project: ey_api_hmac
93
- rubygems_version: 1.8.10
93
+ rubygems_version: 1.8.12
94
94
  signing_key:
95
95
  specification_version: 3
96
96
  summary: HMAC Rack basic implementation for Engine Yard services