rotp 1.5.0 → 1.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.markdown +5 -0
- data/lib/rotp/hotp.rb +16 -0
- data/lib/rotp/totp.rb +1 -2
- data/lib/rotp/version.rb +1 -1
- data/lib/rotp.rb +4 -2
- data/spec/hotp_spec.rb +14 -0
- data/spec/totp_spec.rb +0 -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: 2f0dbf99a0880ce75c5936772e82623ca5c83d94
|
4
|
+
data.tar.gz: caaae71f337eb86af23afd0ffc38a5f318121e5d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0df2b27a1a0a078a3458746eaeacf5b1461858b26fb74a5774fa441e9897546dbc2ce3767854812613a69d520c64c9a04a4c5f62a6f91e885b02ff0c27c4f2a9
|
7
|
+
data.tar.gz: fed6bf9cdb5c28d8e1acdd7e39ba7211e8fe943530f589e0739e4b446973236d892aede78144f4a54c467179329f5ad9a5c576901e63b63230f0d51b8e5a2175
|
data/README.markdown
CHANGED
@@ -92,6 +92,11 @@ Now run the following and compare the output
|
|
92
92
|
|
93
93
|
### Changelog
|
94
94
|
|
95
|
+
#### 1.6.0
|
96
|
+
|
97
|
+
- Add verify_with_retries to HOTP
|
98
|
+
- Fix 'cgi' require and global DEFAULT_INTERVAL
|
99
|
+
|
95
100
|
#### 1.5.0
|
96
101
|
|
97
102
|
- Add support for "issuer" parameter on provisioning url
|
data/lib/rotp/hotp.rb
CHANGED
@@ -15,6 +15,22 @@ module ROTP
|
|
15
15
|
super(otp, self.at(counter))
|
16
16
|
end
|
17
17
|
|
18
|
+
# Verifies the OTP passed in against the current time OTP, with a given number of retries.
|
19
|
+
# Returns the counter that was verified successfully
|
20
|
+
# @param [String/Integer] otp the OTP to check against
|
21
|
+
# @param [Integer] initial counter the counter of the OTP
|
22
|
+
# @param [Integer] number of retries
|
23
|
+
def verify_with_retries(otp, initial_count, retries = 1)
|
24
|
+
return false if retries <= 0
|
25
|
+
|
26
|
+
1.upto(retries) do |counter|
|
27
|
+
current_counter = initial_count + counter
|
28
|
+
return current_counter if verify(otp, current_counter)
|
29
|
+
end
|
30
|
+
|
31
|
+
false
|
32
|
+
end
|
33
|
+
|
18
34
|
# Returns the provisioning URI for the OTP
|
19
35
|
# This can then be encoded in a QR Code and used
|
20
36
|
# to provision the Google Authenticator app
|
data/lib/rotp/totp.rb
CHANGED
data/lib/rotp/version.rb
CHANGED
data/lib/rotp.rb
CHANGED
data/spec/hotp_spec.rb
CHANGED
@@ -24,6 +24,20 @@ describe ROTP::HOTP do
|
|
24
24
|
params["secret"].first.should == "a" * 32
|
25
25
|
end
|
26
26
|
|
27
|
+
context "with retries" do
|
28
|
+
it "should verify that retry is a valid number" do
|
29
|
+
subject.verify_with_retries(161024, @counter, -1).should be_false
|
30
|
+
subject.verify_with_retries(161024, @counter, 0).should be_false
|
31
|
+
end
|
32
|
+
|
33
|
+
it "should verify up to the total number of retries and return the counter" do
|
34
|
+
subject.verify_with_retries(161024, @counter - 10, 10).should == @counter
|
35
|
+
end
|
36
|
+
|
37
|
+
it "should verify that retry is a valid number" do
|
38
|
+
subject.verify_with_retries(161024, @counter - 20, 10).should be_false
|
39
|
+
end
|
40
|
+
end
|
27
41
|
end
|
28
42
|
|
29
43
|
describe "HOTP example values from the rfc" do
|
data/spec/totp_spec.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rotp
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mark Percival
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-
|
11
|
+
date: 2013-12-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|