ExSwan.Validator (exswan v0.1.0)
View SourceValidation functions for WebAuthn data structures and security requirements.
This module provides comprehensive validation for WebAuthn operations, ensuring compliance with the WebAuthn specification and security best practices.
Summary
Functions
Validates a challenge value meets WebAuthn requirements.
Validates attestation creation options structure.
Validates credential ID format and length.
Validates origin against allowed origins list.
Validates public key credential parameters list.
Validates assertion request options structure.
Validates relying party identifier format.
Validates timeout value is within acceptable range.
Validates user handle requirements.
Functions
Validates a challenge value meets WebAuthn requirements.
Challenges must be at least 16 bytes (128 bits) of random data.
Examples
iex> ExSwan.Validator.validate_challenge(<<1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16>>)
:ok
iex> ExSwan.Validator.validate_challenge(<<1, 2, 3>>)
{:error, :challenge_too_short}
@spec validate_creation_options(ExSwan.Attestation.CreationOptions.t()) :: :ok | {:error, atom()}
Validates attestation creation options structure.
Validates credential ID format and length.
Validates origin against allowed origins list.
@spec validate_pub_key_cred_params([ExSwan.Credential.Parameters.t()]) :: :ok | {:error, atom()}
Validates public key credential parameters list.
@spec validate_request_options(ExSwan.Assertion.RequestOptions.t()) :: :ok | {:error, atom()}
Validates assertion request options structure.
Validates relying party identifier format.
The RP ID must be a valid domain name.
@spec validate_timeout(pos_integer() | nil) :: :ok | {:error, atom()}
Validates timeout value is within acceptable range.
Validates user handle requirements.
User handles should be unique, random identifiers of at most 64 bytes.