Class: WebAuthn::AuthenticatorAttestationResponse

Inherits:
AuthenticatorResponse show all
Extended by:
Forwardable
Defined in:
lib/webauthn/authenticator_attestation_response.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from AuthenticatorResponse

#client_data, #valid?

Constructor Details

#initialize(attestation_object:, **options) ⇒ AuthenticatorAttestationResponse

Returns a new instance of AuthenticatorAttestationResponse.



33
34
35
36
37
38
# File 'lib/webauthn/authenticator_attestation_response.rb', line 33

def initialize(attestation_object:, **options)
  super(**options)

  @attestation_object_bytes = attestation_object
  @relying_party = relying_party
end

Instance Attribute Details

#attestation_trust_pathObject (readonly)

Returns the value of attribute attestation_trust_path.



31
32
33
# File 'lib/webauthn/authenticator_attestation_response.rb', line 31

def attestation_trust_path
  @attestation_trust_path
end

#attestation_typeObject (readonly)

Returns the value of attribute attestation_type.



31
32
33
# File 'lib/webauthn/authenticator_attestation_response.rb', line 31

def attestation_type
  @attestation_type
end

Class Method Details

.from_client(response, relying_party: WebAuthn.configuration.relying_party) ⇒ Object



21
22
23
24
25
26
27
28
29
# File 'lib/webauthn/authenticator_attestation_response.rb', line 21

def self.from_client(response, relying_party: WebAuthn.configuration.relying_party)
  encoder = relying_party.encoder

  new(
    attestation_object: encoder.decode(response["attestationObject"]),
    client_data_json: encoder.decode(response["clientDataJSON"]),
    relying_party: relying_party
  )
end

Instance Method Details

#attestation_objectObject



51
52
53
# File 'lib/webauthn/authenticator_attestation_response.rb', line 51

def attestation_object
  @attestation_object ||= WebAuthn::AttestationObject.deserialize(attestation_object_bytes, relying_party)
end

#verify(expected_challenge, expected_origin = nil, user_verification: nil, rp_id: nil) ⇒ Object



40
41
42
43
44
45
46
47
48
49
# File 'lib/webauthn/authenticator_attestation_response.rb', line 40

def verify(expected_challenge, expected_origin = nil, user_verification: nil, rp_id: nil)
  super

  verify_item(:attested_credential)
  if relying_party.verify_attestation_statement
    verify_item(:attestation_statement)
  end

  true
end