pub struct WebauthnBuilder<'a> { /* private fields */ }
Expand description

A constructor for a new Webauthn instance. This accepts and configures a number of site-wide properties that apply to all webauthn operations of this service.

Implementations§

source§

impl<'a> WebauthnBuilder<'a>

source

pub fn new(rp_id: &'a str, rp_origin: &'a Url) -> WebauthnResult<Self>

Initiate a new builder. This takes the relying party id and relying party origin.

Safety

rp_id is what Credentials (Authenticators) bind themself to - rp_id can NOT be changed without breaking all of your users’ associated credentials in the future!

Examples
use webauthn_rs::prelude::*;

let rp_id = "example.com";
let rp_origin = Url::parse("https://idm.example.com")
    .expect("Invalid URL");
let mut builder = WebauthnBuilder::new(rp_id, &rp_origin)
    .expect("Invalid configuration");
Errors

rp_id must be an effective domain of rp_origin. This means that if you are hosting https://idm.example.com, rp_id must be idm.example.com, example.com or com.

use webauthn_rs::prelude::*;

let rp_id = "example.com";
let rp_origin = Url::parse("https://idm.different.com")
    .expect("Invalid URL");
assert!(WebauthnBuilder::new(rp_id, &rp_origin).is_err());
source

pub fn allow_subdomains(self, allow: bool) -> Self

Setting this flag to true allows subdomains to be considered valid in Webauthn operations. An example of this is if you wish for https://au.idm.example.com to be a valid domain for Webauthn when the configuration is https://idm.example.com. Generally this occurs when you have a centralised IDM system, but location specific systems with DNS based redirection or routing.

If in doubt, do NOT change this value. Defaults to “false”.

source

pub fn allow_any_port(self, allow: bool) -> Self

Setting this flag skips port checks on origin matches

source

pub fn append_allowed_origin(self, origin: &Url) -> Self

Set extra origins to be considered valid in Webauthn operations. A common example of this is enabling use with iOS or Android native “webauthn-like” APIs, which return different app-specific origins than a web browser would.

source

pub fn rp_name(self, rp_name: &'a str) -> Self

Set the relying party name. This may be shown to the user. This value can be changed in the future without affecting credentials that have already registered.

If not set, defaults to rp_id.

source

pub fn danger_set_user_presence_only_security_keys(self, enable: bool) -> Self

Available on crate feature danger-user-presence-only-security-keys only.

Enable security keys to only require user presence, rather than enforcing their user-verification state.

requires feature danger-user-presence-only-security-keys

source

pub fn build(self) -> WebauthnResult<Webauthn>

Complete the construction of the Webauthn instance. If an invalid configuration setting is found, an Error will be returned.

Examples
use webauthn_rs::prelude::*;

let rp_id = "example.com";
let rp_origin = Url::parse("https://idm.example.com")
    .expect("Invalid URL");
let mut builder = WebauthnBuilder::new(rp_id, &rp_origin)
    .expect("Invalid configuration");
let webauthn = builder.build()
    .expect("Invalid configuration");

Trait Implementations§

source§

impl<'a> Debug for WebauthnBuilder<'a>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'a> RefUnwindSafe for WebauthnBuilder<'a>

§

impl<'a> Send for WebauthnBuilder<'a>

§

impl<'a> Sync for WebauthnBuilder<'a>

§

impl<'a> Unpin for WebauthnBuilder<'a>

§

impl<'a> UnwindSafe for WebauthnBuilder<'a>

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
§

impl<'a, T> AsTaggedExplicit<'a> for T
where T: 'a,

§

fn explicit(self, class: Class, tag: u32) -> TaggedParser<'a, Explicit, Self>

§

impl<'a, T> AsTaggedImplicit<'a> for T
where T: 'a,

§

fn implicit( self, class: Class, constructed: bool, tag: u32 ) -> TaggedParser<'a, Implicit, Self>

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> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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, U> TryFrom<U> for T
where U: Into<T>,

§

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>,

§

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.
§

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

§

fn vzip(self) -> V

source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more