api_signature 0.1.4 → 0.1.5

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: bd22eb19bbddfaa7c7aba11b219f28398bffeab7
4
- data.tar.gz: 572b91ca9bf45328948793acb944f41fb34b923f
3
+ metadata.gz: ec6eb5396b10ed59fb91d79b2163a7baab9f74c7
4
+ data.tar.gz: 1faac38e423e0c420a6d5f4c46a1096341e270af
5
5
  SHA512:
6
- metadata.gz: 0b5112e733ce5b58372e8814ff5d169315c6ec15c3ecef72d35f2ea4d8a896bdb7873c07ce2e365eaf532e1ade33f17bf18e5882c9c16aabafc1be605901bfa6
7
- data.tar.gz: f2c29427c814f572e9a5002e5bfc575378131469662cf5dfcd6a77cc9df7b3f57d155006c6d5d24bd441a3c9fce1c4894e3f3966d08f57913350133f7edfb822
6
+ metadata.gz: ac924e7bebbfb969e93b2e1ac8f0616200b89bb1910faac04c3d820095ac5965eb56a01d2e525b071eaa74d9226dad31c03c0daeae532e19cd08a2c12de45e37
7
+ data.tar.gz: c8f83d915efef5e558789aefb76aa5b27bf6da531a6e4ba6ad18e59c84c5a93ea93982cd586cdb44258f7fc241409b5943a6ff2bc49c02968c898a209679ba8e
data/README.md CHANGED
@@ -97,7 +97,7 @@ options = {
97
97
  request_method: 'GET',
98
98
  path: '/api/v1/some_path'
99
99
  access_key: 'client public api_key',
100
- timestamp: Time.zone.now.to_i
100
+ timestamp: Time.now.utc.to_i
101
101
  }
102
102
 
103
103
  signature = ApiSignature::Generator.new(options).generate_signature('api_secret')
@@ -2,7 +2,6 @@
2
2
 
3
3
  require 'api_signature/version'
4
4
  require 'active_support/time'
5
- require 'active_support/time_with_zone'
6
5
  require 'active_support/core_ext/class'
7
6
  require 'active_support/core_ext/object/try'
8
7
 
@@ -6,10 +6,11 @@ require 'digest/sha1'
6
6
  module ApiSignature
7
7
  class Generator
8
8
  SPLITTER = '|'
9
- TTL = 2.hours
10
9
 
11
10
  delegate :valid?, :expired?, :timestamp, to: :validator
12
11
 
12
+ attr_reader :options
13
+
13
14
  def initialize(options = {})
14
15
  @options = options
15
16
  end
@@ -22,7 +23,7 @@ module ApiSignature
22
23
  private
23
24
 
24
25
  def validator
25
- Validator.new(@options)
26
+ Validator.new(options)
26
27
  end
27
28
 
28
29
  def digest
@@ -31,9 +32,9 @@ module ApiSignature
31
32
 
32
33
  def string_to_sign
33
34
  [
34
- @options[:request_method],
35
- @options[:path],
36
- @options[:access_key],
35
+ options[:request_method],
36
+ options[:path],
37
+ options[:access_key],
37
38
  timestamp.to_i
38
39
  ].map(&:to_s).join(SPLITTER)
39
40
  end
@@ -31,7 +31,7 @@ module ApiSignature
31
31
  request_method: http_method.to_s.upcase,
32
32
  path: path,
33
33
  access_key: access_key,
34
- timestamp: Time.zone.now.to_i
34
+ timestamp: Time.now.utc.to_i
35
35
  }
36
36
  end
37
37
  end
@@ -6,7 +6,7 @@ module ApiSignature
6
6
 
7
7
  def initialize(options)
8
8
  @options = options
9
- @timestamp = Time.zone.at(@options[:timestamp].to_i)
9
+ @timestamp = Time.at(@options[:timestamp].to_i).utc
10
10
  end
11
11
 
12
12
  def valid?(signature, secret)
@@ -33,7 +33,7 @@ module ApiSignature
33
33
  end
34
34
 
35
35
  def ttl
36
- ApiSignature.signature_ttl || TTL
36
+ ApiSignature.signature_ttl
37
37
  end
38
38
  end
39
39
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ApiSignature
4
- VERSION = '0.1.4'
4
+ VERSION = '0.1.5'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: api_signature
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Igor Galeta
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: exe
11
11
  cert_chain: []
12
- date: 2018-09-14 00:00:00.000000000 Z
12
+ date: 2019-05-27 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler