yubikey 1.3.0 → 1.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.md +8 -11
- data/lib/yubikey.rb +6 -2
- data/lib/yubikey/configuration.rb +42 -0
- data/lib/yubikey/otp_verify.rb +5 -5
- metadata +2 -1
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# yubikey
|
2
2
|
|
3
|
-
[](https://travis-ci.org/titanous/yubikey)
|
4
4
|
|
5
5
|
## Description
|
6
6
|
|
@@ -31,7 +31,7 @@ begin
|
|
31
31
|
otp = Yubikey::OTP::Verify.new(:api_id => 1234,
|
32
32
|
:api_key => 'NiSwGZBQ0gTbwXbRGWAf4kM5xXg=',
|
33
33
|
:otp => 'dteffujehknhfjbrjnlnldnhcujvddbikngjrtgh')
|
34
|
-
|
34
|
+
|
35
35
|
if otp.valid?
|
36
36
|
p 'valid OTP'
|
37
37
|
elsif otp.replayed?
|
@@ -57,14 +57,11 @@ Then run bundle install.
|
|
57
57
|
## Copyright
|
58
58
|
|
59
59
|
### Ruby library
|
60
|
-
|
61
|
-
|
62
|
-
|
60
|
+
|
61
|
+
Written by [Jonathan Rudenberg](https://github.com/titanous). Copyright (c) 2009 Jonathan Rudenberg
|
62
|
+
|
63
|
+
The MIT License. See [LICENSE](https://github.com/titanous/yubikey/blob/master/LICENSE).
|
63
64
|
|
64
65
|
### Contributors
|
65
|
-
|
66
|
-
|
67
|
-
- [Russell Smith](https://github.com/ukd1)
|
68
|
-
- [Chris Lundquist](https://github.com/ChrisLundquist)
|
69
|
-
- [Maarten van Grootel](https://github.com/maartenvg)
|
70
|
-
- [Chris Benedict](https://github.com/chrisbdaemon)
|
66
|
+
|
67
|
+
[List of contributors](https://github.com/titanous/yubikey/graphs/contributors)
|
data/lib/yubikey.rb
CHANGED
@@ -4,9 +4,13 @@ $LOAD_PATH.unshift(File.dirname(__FILE__)) unless
|
|
4
4
|
require 'net/https'
|
5
5
|
require 'openssl'
|
6
6
|
|
7
|
-
|
8
|
-
|
7
|
+
require 'yubikey/configuration'
|
9
8
|
require 'yubikey/hex'
|
10
9
|
require 'yubikey/modhex'
|
11
10
|
require 'yubikey/otp'
|
12
11
|
require 'yubikey/otp_verify'
|
12
|
+
|
13
|
+
module Yubikey
|
14
|
+
extend Configuration
|
15
|
+
end
|
16
|
+
|
@@ -0,0 +1,42 @@
|
|
1
|
+
module Yubikey
|
2
|
+
# Defines constants and methods related to configuration
|
3
|
+
module Configuration
|
4
|
+
# An array of valid keys in the options hash when configuring a Yubikey::OTP::Verify
|
5
|
+
VALID_OPTIONS_KEYS = [
|
6
|
+
:api_id,
|
7
|
+
:api_key,
|
8
|
+
].freeze
|
9
|
+
|
10
|
+
# By default, don't have an api_id
|
11
|
+
DEFAULT_API_ID = nil
|
12
|
+
|
13
|
+
# By default, don't have an api_key
|
14
|
+
DEFAULT_API_KEY = nil
|
15
|
+
|
16
|
+
# @private
|
17
|
+
attr_accessor *VALID_OPTIONS_KEYS
|
18
|
+
|
19
|
+
# When this module is extended, set all configuration options to their default values
|
20
|
+
def self.extended(base)
|
21
|
+
base.reset
|
22
|
+
end
|
23
|
+
|
24
|
+
# Convenience method to allow configuration options to be set in a block
|
25
|
+
def configure
|
26
|
+
yield self
|
27
|
+
end
|
28
|
+
|
29
|
+
# Create a hash of options and their values
|
30
|
+
def options
|
31
|
+
VALID_OPTIONS_KEYS.inject({}) do |option, key|
|
32
|
+
option.merge!(key => send(key))
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
# Reset all configuration options to defaults
|
37
|
+
def reset
|
38
|
+
self.api_id = DEFAULT_API_ID
|
39
|
+
self.api_key = DEFAULT_API_KEY
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
data/lib/yubikey/otp_verify.rb
CHANGED
@@ -10,13 +10,13 @@ module Yubikey
|
|
10
10
|
attr_reader :status
|
11
11
|
|
12
12
|
def initialize(args)
|
13
|
-
|
14
|
-
|
13
|
+
@api_key = args[:api_key] || Yubikey.api_key
|
14
|
+
@api_id = args[:api_id] || Yubikey.api_id
|
15
|
+
raise(ArgumentError, "Must supply API ID") if @api_id.nil?
|
16
|
+
raise(ArgumentError, "Must supply API Key") if @api_key.nil?
|
17
|
+
|
15
18
|
raise(ArgumentError, "Must supply OTP") if args[:otp].nil?
|
16
19
|
|
17
|
-
@api_key = args[:api_key]
|
18
|
-
@api_id = args[:api_id]
|
19
|
-
|
20
20
|
@url = args[:url] || API_URL
|
21
21
|
@nonce = args[:nonce] || OTP::Verify.generate_nonce(32)
|
22
22
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: yubikey
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.3.
|
4
|
+
version: 1.3.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -21,6 +21,7 @@ extra_rdoc_files:
|
|
21
21
|
files:
|
22
22
|
- examples/otp.rb
|
23
23
|
- lib/yubikey.rb
|
24
|
+
- lib/yubikey/configuration.rb
|
24
25
|
- lib/yubikey/hex.rb
|
25
26
|
- lib/yubikey/modhex.rb
|
26
27
|
- lib/yubikey/otp.rb
|