u2f_ex v0.5.0 U2FEx

Handles registration and authentication of incoming U2F requests.

Link to this section Summary

Functions

Finishes authentication. Once this has passed, the user is deemed to have sufficiently proved their identity

Finishes registration. You’ll need to persist the data in KeyMetadata struct to whatever database your heart desires

Starts authentication by using the previously stored key metadata to force the requesting user prove their identity. Send the resulting map to the u2f device

Begins a registration request by creating a challenge. You should send the resulting data to the u2f device

Link to this section Functions

Link to this function finish_authentication(user_id, device_response)
finish_authentication(user_id :: String.t(), device_response :: binary()) ::
  :ok
  | {:error, :signature_verification_failed}
  | {:error, :public_key_not_found}
  | {:error, atom()}

Finishes authentication. Once this has passed, the user is deemed to have sufficiently proved their identity.

Link to this function finish_registration(user_id, device_response)
finish_registration(user_id :: String.t(), device_response :: binary()) ::
  {:ok, U2FEx.KeyMetadata.t()}

Finishes registration. You’ll need to persist the data in KeyMetadata struct to whatever database your heart desires.

Link to this function start_authentication(user_id)
start_authentication(user_id :: String.t()) ::
  {:ok, auth_request :: %{challenge: String.t(), registered_keys: [map()]}}
  | {:error, atom()}

Starts authentication by using the previously stored key metadata to force the requesting user prove their identity. Send the resulting map to the u2f device.

Link to this function start_registration(user_id)
start_registration(user_id :: String.t()) ::
  {:ok,
   registration_request :: %{
     version: String.t(),
     challenge: String.t(),
     appId: String.t()
   }}
  | {:error, :failed_to_store_challenge}

Begins a registration request by creating a challenge. You should send the resulting data to the u2f device.