Class: OmniAuth::Yubikey::Verifier

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

Constant Summary collapse

DEFAULT_API_URL =
"https://api.yubico.com/wsapi/"

Instance Method Summary collapse

Constructor Details

#initialize(api_id, api_key, api_url = DEFAULT_API_URL) ⇒ Verifier

Returns a new instance of Verifier.



10
11
12
13
# File 'lib/omniauth/yubikey/verifier.rb', line 10

def initialize(api_id, api_key, api_url = DEFAULT_API_URL)
  @api_id, @api_key = api_id, api_key
  @api_url = api_url || DEFAULT_API_URL
end

Instance Method Details

#verify(otp) ⇒ Object



15
16
17
18
# File 'lib/omniauth/yubikey/verifier.rb', line 15

def verify(otp)
  response = get_response(otp)
  Result.new(otp, response)
end

#verify!(otp) ⇒ Object

Raises:



20
21
22
23
24
# File 'lib/omniauth/yubikey/verifier.rb', line 20

def verify!(otp)
  result = verify(otp)
  raise OtpError, "Received error: #{result.status}" unless result.valid?
  result
end