Struct Client

Source
pub struct Client<S, U, P>{ /* private fields */ }
Expand description

A Client represents a Webauthn client. Users of this struct should supply a CredentialStore, a UserValidationMethod and, optionally, an implementation of public_suffix::EffectiveTLDProvider.

The tld_provider is used to verify effective Top-Level Domains for request origins presented to the client. Most applications can use the new() function, which creates a Client with a default provider implementation. Use new_with_custom_tld_provider() to provide a custom EffectiveTLDProvider if your application needs to interpret eTLDs differently from the Mozilla Public Suffix List.

Implementations§

Source§

impl<S, U> Client<S, U, PublicSuffixList>

Source

pub fn new(authenticator: Authenticator<S, U>) -> Self

Create a Client with a given Authenticator that uses the default TLD verifier provided by [public_suffix].

Source§

impl<S, U, P> Client<S, U, P>
where S: CredentialStore + Sync, U: UserValidationMethod<PasskeyItem = <S as CredentialStore>::PasskeyItem> + Sync, P: EffectiveTLDProvider + Sync + 'static,

Source

pub fn new_with_custom_tld_provider( authenticator: Authenticator<S, U>, custom_provider: P, ) -> Self

Create a Client with a given Authenticator and a custom TLD provider that implements [public_suffix::EffectiveTLDProvider].

Source

pub fn allows_insecure_localhost(self, is_allowed: bool) -> Self

Allows the internal RpIdVerifier to pass through localhost requests.

Source

pub fn authenticator(&self) -> &Authenticator<S, U>

Read access to the Client’s Authenticator.

Source

pub fn authenticator_mut(&mut self) -> &mut Authenticator<S, U>

Write access to the Client’s Authenticator.

Source

pub async fn register<D: ClientData<E>, E: Serialize + Clone>( &mut self, origin: impl Into<Origin<'_>>, request: CredentialCreationOptions, client_data: D, ) -> Result<CreatedPublicKeyCredential, WebauthnError>

Register a webauthn request from the given origin.

Returns either a webauthn::CreatedPublicKeyCredential on success or some WebauthnError

Source

pub async fn authenticate<D: ClientData<E>, E: Serialize + Clone>( &mut self, origin: impl Into<Origin<'_>>, request: CredentialRequestOptions, client_data: D, ) -> Result<AuthenticatedPublicKeyCredential, WebauthnError>

Authenticate a Webauthn request.

Returns either an webauthn::AuthenticatedPublicKeyCredential on success or some WebauthnError.

Auto Trait Implementations§

§

impl<S, U, P> Freeze for Client<S, U, P>
where S: Freeze, U: Freeze,

§

impl<S, U, P> RefUnwindSafe for Client<S, U, P>

§

impl<S, U, P> Send for Client<S, U, P>
where S: Send, U: Send, P: Send,

§

impl<S, U, P> Sync for Client<S, U, P>

§

impl<S, U, P> Unpin for Client<S, U, P>
where S: Unpin, U: Unpin,

§

impl<S, U, P> UnwindSafe for Client<S, U, P>
where S: UnwindSafe, U: UnwindSafe, P: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> ErasedDestructor for T
where T: 'static,