RpIdVerifier

Struct RpIdVerifier 

Source
pub struct RpIdVerifier<P> { /* private fields */ }
Expand description

Wrapper struct for verifying that a given RpId matches the request’s origin.

While most cases should not use this type directly and instead use Client, there are some cases that warrant the need for checking an RpId in the same way that the client does, but without the rest of pieces that the client needs.

Implementations§

Source§

impl<P> RpIdVerifier<P>
where P: EffectiveTLDProvider + Sync + 'static,

Source

pub fn new(tld_provider: P) -> Self

Create a new Verifier with a given TLD provider. Most cases should just use public_suffix::DEFAULT_PROVIDER.

Source

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

Allows RpIdVerifier::assert_domain to pass through requests from localhost

Source

pub fn assert_domain<'a>( &self, origin: &'a Origin<'_>, rp_id: Option<&'a str>, ) -> Result<&'a str, WebauthnError>

Parse the given Relying Party Id and verify it against the origin url of the request.

This follows the steps defined in: https://html.spec.whatwg.org/multipage/browsers.html#is-a-registrable-domain-suffix-of-or-is-equal-to

Returns the effective domain on success or some WebauthnError

Source

pub fn is_valid_rp_id(&self, rp_id: &str) -> bool

Parse a given Relying Party ID and assert that it is valid to act as such.

This method is only to assert that an RP ID passes the required checks. In order to ensure that a request’s origin is in accordance with it’s claimed RP ID, Self::assert_domain should be used.

There are several checks that an RP ID must pass:

  1. An RP ID set to localhost is only allowed when explicitly enabled with Self::allows_insecure_localhost.
  2. An RP ID must not be part of the [public suffix list], since that would allow it to act as a credential for unrelated services by other entities.

Auto Trait Implementations§

§

impl<P> Freeze for RpIdVerifier<P>

§

impl<P> RefUnwindSafe for RpIdVerifier<P>
where P: RefUnwindSafe,

§

impl<P> Send for RpIdVerifier<P>
where P: Send,

§

impl<P> Sync for RpIdVerifier<P>
where P: Sync,

§

impl<P> Unpin for RpIdVerifier<P>

§

impl<P> UnwindSafe for RpIdVerifier<P>
where 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,