access_token 0.1.1 → 0.1.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: 155a28989f2b3d9d182d2355225eb9e5f11136cb
4
- data.tar.gz: d5d48fa77a2e3efb863f5c7c38ad32177c727fad
3
+ metadata.gz: e246af0e94a0d8c7632d4370f5a117fce1e469bb
4
+ data.tar.gz: b83d79d4804ec42c9f40e4c5b66620637c7677d3
5
5
  SHA512:
6
- metadata.gz: 89b733cafcff734e853b3e26f44323db5eb1fe68337cb7ec192cdf896950cc85657d7a4d72367e02b30486a4b74b9cc5667de5a230f62e3b599a2ec0c713cea0
7
- data.tar.gz: de4ee7a175851ef2ca3c0818b23106d77153a58332f7ae95f58292abfb04cc83a193d0cf6bc30dacc8b260f2cf2ea069441f1daf229b1b1ca2b8ad8902a12dca
6
+ metadata.gz: 251de5820ba056112f3ab9f8c25da1aaefb6bf6f87c33cb5c7c1dee58019aec4eb6aab3d7556758774d4ffed68ae4a68029a0c8b1f341262517e49bd3b02aaac
7
+ data.tar.gz: 5b295898302875abc0d2f0dd4d7160b8ff4506df015f90085aa800ef2482fe9709d87e2c4e47cca3ea14d9351111248b4f7110db74b35376e1d37de91128cce2
@@ -1,5 +1,13 @@
1
1
  # Changelog
2
2
 
3
+ #### v0.1.2 — unreleased
4
+
5
+ - Add secure comparison to avoid timing attack.
6
+
7
+ #### v0.1.1 - Sep 13, 2015
8
+
9
+ - Replace multiple Redis command calls (multi + set + expires) for just one (setex).
10
+
3
11
  #### v0.1.0 - May 31, 2015
4
12
 
5
13
  - Initial release
@@ -69,7 +69,7 @@ class AccessToken
69
69
 
70
70
  return unless data
71
71
  return unless fresh?(data[TIME_KEY])
72
- return unless request_signature == data[SIGNATURE_KEY]
72
+ return unless secure_compare?(request_signature, data[SIGNATURE_KEY])
73
73
 
74
74
  data[ID_KEY]
75
75
  end
@@ -81,4 +81,13 @@ class AccessToken
81
81
  def fresh?(timestamp)
82
82
  timestamp > Time.now.to_i - ttl
83
83
  end
84
+
85
+ def secure_compare?(a, b)
86
+ return false if a.blank? || b.blank? || a.bytesize != b.bytesize
87
+ l = a.unpack "C#{a.bytesize}"
88
+
89
+ res = 0
90
+ b.each_byte { |byte| res |= byte ^ l.shift }
91
+ res == 0
92
+ end
84
93
  end
@@ -1,3 +1,3 @@
1
1
  class AccessToken
2
- VERSION = '0.1.1'
2
+ VERSION = '0.1.2'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: access_token
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nando Vieira
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2015-09-13 00:00:00.000000000 Z
11
+ date: 2015-12-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: parsel
@@ -317,3 +317,4 @@ signing_key:
317
317
  specification_version: 4
318
318
  summary: Access token for client-side and API authentication.
319
319
  test_files: []
320
+ has_rdoc: