Class: Unmagic::Passkeys::WebAuthn::Authenticator::AttestationResponse
- Inherits:
-
Response
- Object
- Response
- Unmagic::Passkeys::WebAuthn::Authenticator::AttestationResponse
- Defined in:
- lib/unmagic/passkeys/web_authn/authenticator/attestation_response.rb
Overview
Action Pack WebAuthn Attestation Response
Handles the authenticator response from a WebAuthn registration ceremony. When a user registers a new credential, the authenticator returns an attestation response containing the new public key and credential ID.
Usage
response = Unmagic::Passkeys::WebAuthn::Authenticator::AttestationResponse.new(
client_data_json: params[:response][:clientDataJSON],
attestation_object: params[:response][:attestationObject],
origin: "https://example.com"
)
response.validate!
# Store the credential
credential_id = response.attestation.credential_id
public_key = response.attestation.public_key
Validation
In addition to the base Response validations, this class verifies:
-
The client data type is “webauthn.create”
-
The attestation format has a registered verifier
-
The attestation statement passes format-specific verification
Instance Attribute Summary collapse
-
#attestation_object ⇒ Object
readonly
Returns the value of attribute attestation_object.
Attributes inherited from Response
#client_data_json, #origin, #user_verification
Instance Method Summary collapse
-
#attestation ⇒ Object
Returns the decoded Attestation object, lazily parsed from the raw attestation object bytes.
-
#authenticator_data ⇒ Object
Returns the authenticator data extracted from the attestation object.
-
#initialize(attestation_object:, **attributes) ⇒ AttestationResponse
constructor
A new instance of AttestationResponse.
Methods inherited from Response
#client_data, #relying_party, #validate!
Constructor Details
#initialize(attestation_object:, **attributes) ⇒ AttestationResponse
Returns a new instance of AttestationResponse.
35 36 37 38 |
# File 'lib/unmagic/passkeys/web_authn/authenticator/attestation_response.rb', line 35 def initialize(attestation_object:, **attributes) super(**attributes) @attestation_object = attestation_object end |
Instance Attribute Details
#attestation_object ⇒ Object (readonly)
Returns the value of attribute attestation_object.
30 31 32 |
# File 'lib/unmagic/passkeys/web_authn/authenticator/attestation_response.rb', line 30 def attestation_object @attestation_object end |
Instance Method Details
#attestation ⇒ Object
Returns the decoded Attestation object, lazily parsed from the raw attestation object bytes.
42 43 44 |
# File 'lib/unmagic/passkeys/web_authn/authenticator/attestation_response.rb', line 42 def attestation @attestation ||= Unmagic::Passkeys::WebAuthn::Authenticator::Attestation.wrap(attestation_object) end |
#authenticator_data ⇒ Object
Returns the authenticator data extracted from the attestation object.
47 48 49 |
# File 'lib/unmagic/passkeys/web_authn/authenticator/attestation_response.rb', line 47 def authenticator_data attestation.authenticator_data end |