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 +4 -4
- data/README.md +1 -1
- data/lib/api_signature.rb +0 -1
- data/lib/api_signature/generator.rb +6 -5
- data/lib/api_signature/spec_support/headers_builder.rb +1 -1
- data/lib/api_signature/validator.rb +2 -2
- data/lib/api_signature/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ec6eb5396b10ed59fb91d79b2163a7baab9f74c7
|
4
|
+
data.tar.gz: 1faac38e423e0c420a6d5f4c46a1096341e270af
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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.
|
100
|
+
timestamp: Time.now.utc.to_i
|
101
101
|
}
|
102
102
|
|
103
103
|
signature = ApiSignature::Generator.new(options).generate_signature('api_secret')
|
data/lib/api_signature.rb
CHANGED
@@ -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(
|
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
|
-
|
35
|
-
|
36
|
-
|
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
|
@@ -6,7 +6,7 @@ module ApiSignature
|
|
6
6
|
|
7
7
|
def initialize(options)
|
8
8
|
@options = options
|
9
|
-
@timestamp = Time.
|
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
|
36
|
+
ApiSignature.signature_ttl
|
37
37
|
end
|
38
38
|
end
|
39
39
|
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
|
+
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:
|
12
|
+
date: 2019-05-27 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|