simple-hmac 0.3.1 → 0.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 +4 -4
- data/lib/rest-client/request.rb +1 -8
- data/lib/simple-hmac.rb +0 -1
- data/lib/simple-hmac/helper.rb +11 -0
- data/lib/simple-hmac/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9163d06bbb21ad88fecc7593c9b7c852bbbd0531
|
4
|
+
data.tar.gz: ed7590ce93a7fd060f40deb5558a27868421688d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 20f18e0693252889a7b475d87d67169fce203de500a6996dccb4b64e97f4b6b1e90bfc7d528a91e5c7808e5c29fe7b6488e64cc38887718b6a304998225d8900
|
7
|
+
data.tar.gz: 9b35d75510fadb91a227b7dd535aada1d006efe0ebd01db007a0d6d914e5c60d71ceeae6cf1d512aecde6e1afb3fabb317db80f9cfd40975330d4717aec4693b
|
data/lib/rest-client/request.rb
CHANGED
@@ -6,14 +6,7 @@ module RestClient
|
|
6
6
|
include SimpleHmac::Helper
|
7
7
|
|
8
8
|
def sign!(api_id, api_secret, options={})
|
9
|
-
|
10
|
-
auth_prefix = options.delete :auth_prefix
|
11
|
-
date = Time.now.httpdate
|
12
|
-
processed_headers.merge! 'Date' => date
|
13
|
-
content_type = processed_headers['Content-Type'] || 'text/plain'
|
14
|
-
processed_headers.merge! 'Content-Type' => content_type
|
15
|
-
hmac_token = hmac_token(method, content_type, set_md5_header, url, date, api_secret, options)
|
16
|
-
processed_headers.merge! 'Authorization' => "#{auth_prefix} #{api_id}:#{hmac_token}"
|
9
|
+
sign_headers(processed_headers, method, api_id, api_secret, options)
|
17
10
|
end
|
18
11
|
|
19
12
|
private
|
data/lib/simple-hmac.rb
CHANGED
data/lib/simple-hmac/helper.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
require 'base64'
|
2
2
|
require 'openssl'
|
3
|
+
require 'time'
|
3
4
|
|
4
5
|
module SimpleHmac
|
5
6
|
module Helper
|
@@ -11,5 +12,15 @@ module SimpleHmac
|
|
11
12
|
string_to_sign = data.join(options[:separator])
|
12
13
|
Base64.strict_encode64(OpenSSL::HMAC.digest(options[:algorithm], api_secret, string_to_sign))
|
13
14
|
end
|
15
|
+
|
16
|
+
def sign_headers(headers, verb, api_key, api_secret, options={})
|
17
|
+
options = { auth_prefix: 'WIZYPAY' }.merge(options)
|
18
|
+
auth_prefix = options.delete :auth_prefix
|
19
|
+
date = Time.now.httpdate
|
20
|
+
headers.merge! 'Date' => date
|
21
|
+
content_type = (headers['Content-Type'] ||= 'text/plain')
|
22
|
+
hmac_token = hmac_token(verb, content_type, set_md5_header, url, date, api_secret, options)
|
23
|
+
headers.merge! 'Authorization' => "#{auth_prefix} #{api_key}:#{hmac_token}"
|
24
|
+
end
|
14
25
|
end
|
15
26
|
end
|
data/lib/simple-hmac/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: simple-hmac
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Chaker Nakhli
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-10-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rest-client
|
@@ -117,7 +117,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
117
117
|
version: '0'
|
118
118
|
requirements: []
|
119
119
|
rubyforge_project:
|
120
|
-
rubygems_version: 2.4.
|
120
|
+
rubygems_version: 2.4.5.1
|
121
121
|
signing_key:
|
122
122
|
specification_version: 4
|
123
123
|
summary: Lightweight HMAC implementation for Rails + Restclient.
|