Class: Yubikey::OTP::Verify

Inherits:
Object
  • Object
show all
Defined in:
lib/yubikey/otp_verify.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(args) ⇒ Verify

Returns a new instance of Verify

Raises:

  • (ArgumentError)

12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/yubikey/otp_verify.rb', line 12

def initialize(args)
  @api_key = args[:api_key] || Yubikey.api_key
  @api_id  = args[:api_id]  || Yubikey.api_id
  
  raise(ArgumentError, "Must supply API ID") if @api_id.nil?
  raise(ArgumentError, "Must supply API Key") if @api_key.nil?
  raise(ArgumentError, "Must supply OTP") if args[:otp].nil?

  @url = args[:url] || Yubikey.url
  @nonce = args[:nonce] || OTP::Verify.generate_nonce(32)
  
  @certificate_chain = args[:certificate_chain] || Yubikey.certificate_chain
  @cert_store = OpenSSL::X509::Store.new
  @cert_store.add_file @certificate_chain
  
  verify(args)
end

Instance Attribute Details

#statusObject (readonly)

The raw status from the Yubico server


10
11
12
# File 'lib/yubikey/otp_verify.rb', line 10

def status
  @status
end

Instance Method Details

#replayed?Boolean

Returns:

  • (Boolean)

34
35
36
# File 'lib/yubikey/otp_verify.rb', line 34

def replayed?
  @status == 'REPLAYED_OTP'
end

#valid?Boolean

Returns:

  • (Boolean)

30
31
32
# File 'lib/yubikey/otp_verify.rb', line 30

def valid?
  @status == 'OK'
end