Class: WebAuthn::AttestationStatement::AndroidSafetynet

Inherits:
WebAuthn::AttestationStatement show all
Defined in:
lib/web_authn/attestation_statement/android_safetynet.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(ver:, response:) ⇒ AndroidSafetynet

Returns a new instance of AndroidSafetynet.



6
7
8
9
10
11
12
13
14
# File 'lib/web_authn/attestation_statement/android_safetynet.rb', line 6

def initialize(ver:, response:)
  self.ver = ver
  self.response = response
  self.certs = response.x5c.collect do |x5c|
    OpenSSL::X509::Certificate.new(
      Base64.decode64 x5c
    )
  end
end

Instance Attribute Details

#certsObject

Returns the value of attribute certs.



4
5
6
# File 'lib/web_authn/attestation_statement/android_safetynet.rb', line 4

def certs
  @certs
end

#responseObject

Returns the value of attribute response.



4
5
6
# File 'lib/web_authn/attestation_statement/android_safetynet.rb', line 4

def response
  @response
end

#verObject

Returns the value of attribute ver.



4
5
6
# File 'lib/web_authn/attestation_statement/android_safetynet.rb', line 4

def ver
  @ver
end

Class Method Details

.decode(att_stmt) ⇒ Object



71
72
73
74
75
76
# File 'lib/web_authn/attestation_statement/android_safetynet.rb', line 71

def decode(att_stmt)
  new(
    ver: att_stmt[:ver],
    response: JSON::JWT.decode(att_stmt[:response], :skip_verification)
  )
end

Instance Method Details

#verify!(authenticator_data, client_data_json) ⇒ Object



16
17
18
19
20
21
22
23
24
# File 'lib/web_authn/attestation_statement/android_safetynet.rb', line 16

def verify!(authenticator_data, client_data_json)
  verify_nonce! authenticator_data, client_data_json
  verify_signature!
  verify_certificate!

  unless response[:ctsProfileMatch]
    raise InvalidAttestation, 'Invalid Android Safetynet Response: ctsProfileMatch'
  end
end