Class: WebAuthn::Context::Authentication

Inherits:
WebAuthn::Context show all
Defined in:
lib/web_authn/context/authentication.rb

Instance Attribute Summary collapse

Attributes inherited from WebAuthn::Context

#client_data_json

Instance Method Summary collapse

Methods inherited from WebAuthn::Context

for, #initialize, #registration?, #verify_session!

Constructor Details

This class inherits a constructor from WebAuthn::Context

Instance Attribute Details

#authenticator_dataObject

Returns the value of attribute authenticator_data.



4
5
6
# File 'lib/web_authn/context/authentication.rb', line 4

def authenticator_data
  @authenticator_data
end

Instance Method Details

#authentication?Boolean

Returns:

  • (Boolean)


11
12
13
# File 'lib/web_authn/context/authentication.rb', line 11

def authentication?
  true
end

#verify!(encoded_authenticator_data, sign_count:, signature:, public_key: nil, public_cose_key: nil, digest: OpenSSL::Digest::SHA256.new) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/web_authn/context/authentication.rb', line 15

def verify!(encoded_authenticator_data, sign_count:, signature:, public_key: nil, public_cose_key: nil, digest: OpenSSL::Digest::SHA256.new)
  unless public_key || public_cose_key
    raise ArgumentError, 'missing keyword: public_key or public_cose_key'
  end

  self.authenticator_data = AuthenticatorData.decode(
    Base64.urlsafe_decode64 encoded_authenticator_data
  )
  verify_flags!
  verify_sign_count!(sign_count)
  verify_signature!(public_key, public_cose_key, signature, digest)
  self
end