lib/yubico.rb
# Verify an Yubikey OTP Token. Returns the value of the response variable "status"
#   req = yk.verify( @token, @id )
#     # => STATUS_VARIABLE
# Upon an error, you should use the Yubikey.last_response method for a more detailed collection of
# variables, including the request hash, info and further.
Verify an Yubikey OTP Token. Returns the value of the response variable "status"
req = yk.verify( @token, @id )
=> STATUS_VARIABLE
Upon an error, you should use the Yubikey.last_response method for a more detailed collection of
variables, including the request hash, info and further.
Verify an Yubikey OTP Token . Returns the value of the response variable " status " req = yk . verify ( @token @id ) = > STATUS_VARIABLE Upon an error you should use the Yubikey . last_response method for a more detailed collection of variables including the request hash info and further .
def verify( otp, id = @_id )
		  @_id = id if @_id.nil?
			fullurl = "https://api.yubico.com/wsapi/verify?id="+ (@_id.to_s) +"&otp="+ otp
			url = URI.parse(fullurl)
			http = Net::HTTP.new(url.host, 443)
      http.use_ssl = true
      res = http.get(url.path + "?" + url.query)
		  if ( !(/status=([a-zA-Z0-9_]+)/.match(res.body)) )
		    raise "Response Error: "+ res.body
	      else 
	        @_res = res.body
	      end
		  @_res.scan(/status=([a-zA-Z0-9_]+)[\s]/).first.to_s
		end
def verify ( otp , id = @_id ) @_id = id if @_id . nil? fullurl = "https://api.yubico.com/wsapi/verify?id=" + ( @_id . to_s ) + "&otp=" + otp url = URI . parse ( fullurl ) http = Net :: HTTP . new ( url . host , 443 ) http . use_ssl = true res = http . get ( url . path + "?" + url . query ) if ( ! ( / status=([a-zA-Z0-9_]+) / . match ( res . body ) ) ) raise "Response Error: " + res . body else @_res = res . body end @_res . scan ( / status=([a-zA-Z0-9_]+)[ \s ] / ) . first . to_s end
Verify an Yubikey OTP Token.
Verify an Yubikey OTP Token .
# Set up the full URL for the request, then pass it through the +URI+ gauntlet. # Make the call to the server and return the full response, not just the body (to be used later) # Parse and find the status within the response's body, to verify this is, in fact, what we're looking for. # If it's not, let's raise an error. # Finally, return the response value.
otp
id