KMS.WebAuthn (kms v0.1.0)

Copy Markdown View Source

Server-side WebAuthn/passkey ceremony helpers.

KMS returns JSON-compatible publicKey options for the application server to pass to browser JavaScript. The browser response must be posted back to the application server and then forwarded here for verification.

Summary

Functions

auth_only_private_key()

begin_authentication(kind, ref, opts \\ [])

Begins WebAuthn/passkey authentication for a principal.

Returns a challenge_id and JSON-compatible public_key options for browser navigator.credentials.get/1.

begin_registration(kind, ref, opts \\ [])

Begins WebAuthn/passkey registration for a principal.

Returns a challenge_id and JSON-compatible public_key options for browser navigator.credentials.create/1.

delete_expired_challenges(now \\ DateTime.utc_now())

finish_authentication(challenge_id, response, opts \\ [])

Finishes WebAuthn/passkey authentication.

On success, returns a KMS session that can be used with KMS operations requiring session: authorization.

finish_registration(challenge_id, response, opts \\ [])

Finishes WebAuthn/passkey registration.

response is the browser credential response converted to a plain map. On success, stores an enabled WebAuthn credential for the principal.

issue_factor_challenge(factor, session, opts \\ [])

Issues a WebAuthn challenge for a pending MFA session.

This is used by the WebAuthn factor provider path during KMS.advance_session/2.

verify_factor_challenge(factor, session, attrs, opts \\ [])