Struct CredentialVerifier

Source
pub struct CredentialVerifier<'a, S: NonceStorage> { /* private fields */ }
Expand description

A verifier for NonceCredentials, created by NonceServer::credential_verifier.

This builder-like struct provides a safe and ergonomic API for verifying credentials.

Implementations§

Source§

impl<'a, S: NonceStorage> CredentialVerifier<'a, S>

Source

pub fn with_context(self, context: Option<&'a str>) -> Self

Sets the context for this verification operation.

The context provides an additional layer of isolation for nonces.

Source

pub fn with_secret(self, secret: &'a [u8]) -> Self

Sets the secret key for this verification operation.

This is required for signature verification. Each user/client may have a different secret.

Source

pub async fn verify(self, payload: &[u8]) -> Result<(), NonceError>

Verifies the credential against a standard payload.

This is the recommended verification method for most use cases. It assumes the signature was created on the client using sign(payload).

§Arguments
  • payload: The payload that was signed on the client side.
Source

pub async fn verify_with<F>( self, signature_builder: F, ) -> Result<(), NonceError>
where F: FnOnce(&mut Hmac<Sha256>),

Verifies the credential using custom signature-reconstruction logic.

This method is for advanced scenarios where the signature includes more than just the standard payload.

§Warning

The logic in the signature_builder closure must exactly match the logic used on the client side in sign_with, otherwise verification will fail.

§Arguments
  • signature_builder: A closure to reconstruct the signed data.

Auto Trait Implementations§

§

impl<'a, S> Freeze for CredentialVerifier<'a, S>

§

impl<'a, S> RefUnwindSafe for CredentialVerifier<'a, S>
where S: RefUnwindSafe,

§

impl<'a, S> Send for CredentialVerifier<'a, S>

§

impl<'a, S> Sync for CredentialVerifier<'a, S>

§

impl<'a, S> Unpin for CredentialVerifier<'a, S>

§

impl<'a, S> UnwindSafe for CredentialVerifier<'a, S>
where S: RefUnwindSafe,

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.