Skip to main content

Authentication

Struct Authentication 

Source
pub struct Authentication<const USER_LEN: usize, const DISCOVERABLE: bool> { /* private fields */ }
Expand description

PublicKeyCredential for authentication ceremonies.

Implementations§

Source§

impl<const USER_LEN: usize, const DISCOVERABLE: bool> Authentication<USER_LEN, DISCOVERABLE>

Source

pub fn raw_id(&self) -> CredentialId<&[u8]>

Source

pub const fn response(&self) -> &AuthenticatorAssertion<USER_LEN, DISCOVERABLE>

Source

pub const fn authenticator_attachment(&self) -> AuthenticatorAttachment

Source

pub const fn new( raw_id: CredentialId<Box<[u8]>>, response: AuthenticatorAssertion<USER_LEN, DISCOVERABLE>, authenticator_attachment: AuthenticatorAttachment, ) -> Self

Available on crate feature custom only.

Constructs an Authentication.

Source

pub fn challenge(&self) -> Result<SentChallenge, CollectedClientDataErr>

Returns the associated SentChallenge.

This is useful when wanting to extract the corresponding DiscoverableAuthenticationServerState or NonDiscoverableAuthenticationServerState from an in-memory collection (e.g., MaxLenHashSet) or storage.

Note if CollectedClientData::from_client_data_json returns Ok, then this will return Ok containing the same value as CollectedClientData::challenge; however the converse is not true. This is because this function parses the minimal amount of data possible.

§Errors

Errors iff AuthenticatorAssertion::client_data_json does not contain a base64url-encoded Challenge in the required position.

Source

pub fn challenge_relaxed(&self) -> Result<SentChallenge, SerdeJsonErr>

Available on crate feature serde_relaxed only.

Returns the associated SentChallenge.

This is useful when wanting to extract the corresponding DiscoverableAuthenticationServerState or NonDiscoverableAuthenticationServerState from an in-memory collection (e.g., MaxLenHashSet) or storage.

Note if CollectedClientData::from_client_data_json_relaxed returns Ok, then this will return Ok containing the same value as CollectedClientData::challenge; however the converse is not true. This is because this function attempts to reduce the amount of data parsed.

§Errors

Errors iff AuthenticatorAssertion::client_data_json is invalid JSON after ignoring a leading U+FEFF and replacing any sequences of invalid UTF-8 code units with U+FFFD or challenge does not exist or is not a base64url-encoded Challenge.

Source

pub fn from_json_relaxed<'a>(json: &'a [u8]) -> Result<Self, SerdeJsonErr>
where UserHandle<USER_LEN>: Deserialize<'a>,

Available on crate feature serde_relaxed only.

Convenience function for AuthenticationRelaxed::deserialize.

§Errors

Errors iff AuthenticationRelaxed::deserialize does.

Source

pub fn from_json_custom<'a>(json: &'a [u8]) -> Result<Self, SerdeJsonErr>
where UserHandle<USER_LEN>: Deserialize<'a>,

Available on crate feature serde_relaxed only.

Convenience function for CustomAuthentication::deserialize.

§Errors

Errors iff CustomAuthentication::deserialize does.

Trait Implementations§

Source§

impl<const USER_LEN: usize, const DISCOVERABLE: bool> Debug for Authentication<USER_LEN, DISCOVERABLE>

Source§

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

Formats the value using the given formatter. Read more
Source§

impl<'de, const USER_LEN: usize, const DISCOVERABLE: bool> Deserialize<'de> for Authentication<USER_LEN, DISCOVERABLE>
where UserHandle<USER_LEN>: Deserialize<'de>,

Available on crate feature serde only.
Source§

fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where D: Deserializer<'de>,

Deserializes a struct based on AuthenticationResponseJSON.

Note that unknown and duplicate keys are forbidden; id and rawId are deserialized via CredentialId::deserialize; response is deserialized via AuthenticatorAssertion::deserialize; authenticatorAttachment is null or deserialized via AuthenticatorAttachment::deserialize; clientExtensionResults is deserialized such that it is an empty map or a map that only contains prf which additionally must be null or an AuthenticationExtensionsPRFOutputs such that unknown and duplicate keys are forbidden, enabled is forbidden (including being assigned null), results must not exist, be null, or be an AuthenticationExtensionsPRFValues with no unknown or duplicate keys, first must exist but be null, and second can exist but must be null if so; all required fields in the AuthenticationResponseJSON Web IDL dictionary exist (and are not null); type is "public-key"; and the decoded id and decoded rawId are the same.

Source§

impl<const USER_LEN: usize> From<Authentication<USER_LEN, true>> for NonDiscoverableAuthentication<USER_LEN>

Source§

fn from(value: DiscoverableAuthentication<USER_LEN>) -> Self

Converts to this type from the input type.
Source§

impl<const USER_LEN: usize> TryFrom<Authentication<USER_LEN, false>> for DiscoverableAuthentication<USER_LEN>

Source§

type Error = MissingUserHandleErr

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

fn try_from( value: NonDiscoverableAuthentication<USER_LEN>, ) -> Result<Self, MissingUserHandleErr>

Performs the conversion.

Auto Trait Implementations§

§

impl<const USER_LEN: usize, const DISCOVERABLE: bool> Freeze for Authentication<USER_LEN, DISCOVERABLE>
where AuthenticatorAssertion<USER_LEN, DISCOVERABLE>: Freeze,

§

impl<const USER_LEN: usize, const DISCOVERABLE: bool> RefUnwindSafe for Authentication<USER_LEN, DISCOVERABLE>
where AuthenticatorAssertion<USER_LEN, DISCOVERABLE>: RefUnwindSafe,

§

impl<const USER_LEN: usize, const DISCOVERABLE: bool> Send for Authentication<USER_LEN, DISCOVERABLE>
where AuthenticatorAssertion<USER_LEN, DISCOVERABLE>: Send,

§

impl<const USER_LEN: usize, const DISCOVERABLE: bool> Sync for Authentication<USER_LEN, DISCOVERABLE>
where AuthenticatorAssertion<USER_LEN, DISCOVERABLE>: Sync,

§

impl<const USER_LEN: usize, const DISCOVERABLE: bool> Unpin for Authentication<USER_LEN, DISCOVERABLE>
where AuthenticatorAssertion<USER_LEN, DISCOVERABLE>: Unpin,

§

impl<const USER_LEN: usize, const DISCOVERABLE: bool> UnsafeUnpin for Authentication<USER_LEN, DISCOVERABLE>
where AuthenticatorAssertion<USER_LEN, DISCOVERABLE>: UnsafeUnpin,

§

impl<const USER_LEN: usize, const DISCOVERABLE: bool> UnwindSafe for Authentication<USER_LEN, DISCOVERABLE>
where AuthenticatorAssertion<USER_LEN, DISCOVERABLE>: 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> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

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 = !

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

fn try_from(value: U) -> Result<T, !>

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.