Webs_passkeyWebAuthn passkey authentication.
This module provides primitives to handle passkeys as your authentication mecanism.
While it makes a few choices on what to expose of that terrible mess, it does not prescribe a particular user interface workflow or passkey storage. It is only concerned about extracting data from the client into proper data structures and provides primitives for handling challenges, passkey registrations and verifying client provided assertions.
Note. The support provided by this module is thread-safe.
TODO.
References.
module Challenge : sig ... endUnique, expirable, challenges.
module Aaguid : sig ... endAuthenticator attestation GUIDs (AAGUID).
module Credential_id : sig ... endCredential IDs.
module Public_key : sig ... endPublic keys.
module Passkey : sig ... endPasskeys (client provided public keys).
module Registration : sig ... endRegistrations (client passkey registration).
module Assertion : sig ... endAssertions (client signed challenges).
module Relying_party : sig ... endRelying party (registers and verifies client assertions).
type error = | Invalid_relying_party_origin of {}| Invalid_relying_party_hash of {}| Invalid_client_data_type of {}| Invalid_challenge of Challenge.t| Invalid_signature of {}The type for operation errors.
val error_message : error -> stringerror_message e is an error message for e.
val challenge :
?validity_s:int ->
'a Relying_party.t ->
payload:'a ->
Challenge.tchallenge rp is a challenge generated by rp. Note this library also uses a challenge for register.
val register :
'a Relying_party.t ->
Registration.t ->
('a * Passkey.t, error) Stdlib.resultregister rp r registers a new passkey from registration data r. This verifies that (and only that), in order:
type is webauth.createrp.rp.rpval verify :
'a Relying_party.t ->
Passkey.t ->
Assertion.t ->
('a, error) Stdlib.resultverify rp pub_key assertion is Ok () if assertion is validated by pub_key and a. This verifies that (and only that), in order:
type is webauth.getrp.rp.pub_key.Note. It is your duty to find out which pub_key must be used to validate assertion, by looking them up somewhere via Assertion.credential_id. Note that formally only the Passkey.public_key field is needed to perform the check, the rest is metadata. you can use Passkey.of_public_key if that's the only thing you have.
TODO meanwhile checkout this example.