simple-hmac 0.3.1 → 0.3.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0ad4c0ade66468bfc78ce09e81966985783b3932
4
- data.tar.gz: b8f9b392bba73820219064ba990c78f88851dbbf
3
+ metadata.gz: 9163d06bbb21ad88fecc7593c9b7c852bbbd0531
4
+ data.tar.gz: ed7590ce93a7fd060f40deb5558a27868421688d
5
5
  SHA512:
6
- metadata.gz: fbfe2883dec3ea3d651d1788cb33d571740614d007d78601c629fff5b944cab5b8ed3bb7d7a85108d2b2356e3979dc70239734d63146947dd626d9a88b8875b9
7
- data.tar.gz: 4c2dec9963b3df48de46d9c9855c10ff1ee84b0539cbdd4971329aad3f5537bcd104b5ed369f08c56db0391e8bd183ace208a3931d477693291b71f133884fd5
6
+ metadata.gz: 20f18e0693252889a7b475d87d67169fce203de500a6996dccb4b64e97f4b6b1e90bfc7d528a91e5c7808e5c29fe7b6488e64cc38887718b6a304998225d8900
7
+ data.tar.gz: 9b35d75510fadb91a227b7dd535aada1d006efe0ebd01db007a0d6d914e5c60d71ceeae6cf1d512aecde6e1afb3fabb317db80f9cfd40975330d4717aec4693b
@@ -6,14 +6,7 @@ module RestClient
6
6
  include SimpleHmac::Helper
7
7
 
8
8
  def sign!(api_id, api_secret, options={})
9
- options = { auth_prefix: 'WIZYPAY' }.merge(options)
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
@@ -1,4 +1,3 @@
1
- require 'active_support/core_ext/time/zones'
2
1
  require_relative 'simple-hmac/helper'
3
2
  require_relative 'rest-client/request'
4
3
  require_relative 'action-dispatch/request' if defined?(Rails)
@@ -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
@@ -1,4 +1,4 @@
1
1
  module SimpleHmac
2
- VERSION = '0.3.1'
2
+ VERSION = '0.3.2'
3
3
  end
4
4
 
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.1
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-04-08 00:00:00.000000000 Z
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.6
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.