pub struct VerifierBuilder<'a, Pk, Body, Method, Path> { /* private fields */ }
Expand description

Builder to verify a request against a Tl-Signature header.

§Example

truelayer_signing::VerifierBuilder::pem(public_key)
    .method(truelayer_signing::Method::Post)
    .path("/payouts")
    .require_header("Idempotency-Key")
    .header("X-Whatever", b"aoitbeh")
    .header("Idempotency-Key", idempotency_key)
    .body(body)
    .build_verifier()
    .verify(tl_signature)
    .expect("verify");

Implementations§

source§

impl<'a> VerifierBuilder<'a, PublicKey<'a>, Unset, Unset, Unset>

source

pub fn pem( pem: &'a [u8] ) -> VerifierBuilder<'a, PublicKey<'a>, Unset, Unset, Unset>

Add public key via pem.

source

pub fn jwks( jwk: &'a [u8] ) -> VerifierBuilder<'a, PublicKey<'a>, Unset, Unset, Unset>

Add public key via a jwks.

source§

impl<'a, Pk, Method, Path> VerifierBuilder<'a, Pk, Unset, Method, Path>

source

pub fn body( self, body: &'a [u8] ) -> VerifierBuilder<'a, Pk, &'a [u8], Method, Path>

Add the full received request body.

source§

impl<'a, Pk, Body, Path> VerifierBuilder<'a, Pk, Body, Unset, Path>

source

pub fn method( self, method: Method ) -> VerifierBuilder<'a, Pk, Body, Method, Path>

Add the request method.

source§

impl<'a, Pk, Body, Method> VerifierBuilder<'a, Pk, Body, Method, Unset>

source

pub fn path( self, path: &'a str ) -> VerifierBuilder<'a, Pk, Body, Method, &'a str>

Add the request path, e.g. "/payouts".

§Panics

If path does not start with a ‘/’ char.

source§

impl<'a, Pk, Body, Method, Path> VerifierBuilder<'a, Pk, Body, Method, Path>

source

pub fn header(self, key: &'a str, value: &'a [u8]) -> Self

Add a header name & value. May be called multiple times to add multiple different headers.

All request headers may be added here, any headers not mentioned in the jws signature header will be ignored unless required using [Verifier::require_header].

source

pub fn headers( self, headers: impl IntoIterator<Item = (&'a str, &'a [u8])> ) -> Self

Appends multiple header names & values.

All request headers may be added here, any headers not mentioned in the jws signature header will be ignored unless required using [Verifier::require_header].

§Example
truelayer_signing::VerifierBuilder::pem(public_key)
    .headers([("X-Head-A", "123".as_bytes()), ("X-Head-B", "345".as_bytes())]);
source

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

Require a header name that must be included in the Tl-Signature. May be called multiple times to add multiple required headers.

Signatures missing these will fail verification.

source§

impl<'a> VerifierBuilder<'a, PublicKey<'a>, &'a [u8], Method, &'a str>

source

pub fn build_verifier(self) -> Verifier<'a>

Build a V2 Verifier see Verifier.

requires the public key, body, method, and path to be set to call this function.

source§

impl<'a> VerifierBuilder<'a, PublicKey<'a>, &'a [u8], Unset, Unset>

source

pub fn build_v1_verifier(self) -> VerifierV1<'a>

Build a V1 Verifier see [VerifierV1].

requires the public key and body to be set to call this function.

Trait Implementations§

source§

impl<Pk, Body, Method, Path> Debug for VerifierBuilder<'_, Pk, Body, Method, Path>

Debug does not display key info.

source§

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

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

impl<'a, Pk: Default, Body: Default, Method: Default, Path: Default> Default for VerifierBuilder<'a, Pk, Body, Method, Path>

source§

fn default() -> VerifierBuilder<'a, Pk, Body, Method, Path>

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl<'a, Pk, Body, Method, Path> Freeze for VerifierBuilder<'a, Pk, Body, Method, Path>
where Body: Freeze, Method: Freeze, Path: Freeze, Pk: Freeze,

§

impl<'a, Pk, Body, Method, Path> RefUnwindSafe for VerifierBuilder<'a, Pk, Body, Method, Path>
where Body: RefUnwindSafe, Method: RefUnwindSafe, Path: RefUnwindSafe, Pk: RefUnwindSafe,

§

impl<'a, Pk, Body, Method, Path> Send for VerifierBuilder<'a, Pk, Body, Method, Path>
where Body: Send, Method: Send, Path: Send, Pk: Send,

§

impl<'a, Pk, Body, Method, Path> Sync for VerifierBuilder<'a, Pk, Body, Method, Path>
where Body: Sync, Method: Sync, Path: Sync, Pk: Sync,

§

impl<'a, Pk, Body, Method, Path> Unpin for VerifierBuilder<'a, Pk, Body, Method, Path>
where Body: Unpin, Method: Unpin, Path: Unpin, Pk: Unpin,

§

impl<'a, Pk, Body, Method, Path> UnwindSafe for VerifierBuilder<'a, Pk, Body, Method, Path>
where Body: UnwindSafe, Method: UnwindSafe, Path: UnwindSafe, Pk: 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, 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.