AshAuthentication.Strategy.WebAuthn.Actions
(ash_authentication v5.0.0-rc.7)
Copy Markdown
View Source
Core action implementations for the WebAuthn strategy.
Wraps the wax_ library for FIDO2 ceremony handling and coordinates
with Ash to persist users and credentials.
Summary
Functions
Add a new WebAuthn credential to an existing user.
Generate an authentication challenge.
Delete a credential, refusing to delete the last one.
List all credentials for a user.
Register a new user with a WebAuthn credential.
Generate a registration challenge.
Sign in a user with a WebAuthn credential.
Update the label of a credential.
Functions
@spec add_credential(AshAuthentication.Strategy.WebAuthn.t(), map(), keyword()) :: {:ok, Ash.Resource.record()} | {:error, any()}
Add a new WebAuthn credential to an existing user.
This is used when a user wants to register an additional security key or passkey.
Unlike register/3, this does NOT create a new user - it attaches a credential
to an existing one.
Params should include:
"attestation_object"- Base64url-encoded attestation object from the browser"client_data_json"- Base64url-encoded client data JSON from the browser"label"- Optional human-readable label for the credential
Options must include:
challenge:- The Wax.Challenge used for this ceremonyuser:- The existing user to attach the credential to
@spec authentication_challenge(AshAuthentication.Strategy.WebAuthn.t(), list(), any()) :: {:ok, Wax.Challenge.t()}
Generate an authentication challenge.
@spec delete_credential( AshAuthentication.Strategy.WebAuthn.t(), Ash.Resource.record(), any(), keyword() ) :: :ok | {:error, any()}
Delete a credential, refusing to delete the last one.
@spec list_credentials( AshAuthentication.Strategy.WebAuthn.t(), Ash.Resource.record(), keyword() ) :: {:ok, [Ash.Resource.record()]} | {:error, any()}
List all credentials for a user.
@spec register(AshAuthentication.Strategy.WebAuthn.t(), map(), keyword()) :: {:ok, Ash.Resource.record()} | {:error, any()}
Register a new user with a WebAuthn credential.
@spec registration_challenge(AshAuthentication.Strategy.WebAuthn.t(), any()) :: {:ok, Wax.Challenge.t()}
Generate a registration challenge.
@spec sign_in(AshAuthentication.Strategy.WebAuthn.t(), map(), keyword()) :: {:ok, Ash.Resource.record()} | {:error, any()}
Sign in a user with a WebAuthn credential.
@spec update_credential_label( AshAuthentication.Strategy.WebAuthn.t(), any(), String.t(), keyword() ) :: {:ok, Ash.Resource.record()} | {:error, any()}
Update the label of a credential.