Struct truelayer_signing::VerifierBuilder
source · 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>
impl<'a> VerifierBuilder<'a, PublicKey<'a>, Unset, Unset, Unset>
sourcepub fn pem(
pem: &'a [u8]
) -> VerifierBuilder<'a, PublicKey<'a>, Unset, Unset, Unset>
pub fn pem( pem: &'a [u8] ) -> VerifierBuilder<'a, PublicKey<'a>, Unset, Unset, Unset>
Add public key via pem.
sourcepub fn jwks(
jwk: &'a [u8]
) -> VerifierBuilder<'a, PublicKey<'a>, Unset, Unset, Unset>
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>
impl<'a, Pk, Method, Path> VerifierBuilder<'a, Pk, Unset, Method, Path>
sourcepub fn body(
self,
body: &'a [u8]
) -> VerifierBuilder<'a, Pk, &'a [u8], Method, Path>
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>
impl<'a, Pk, Body, Path> VerifierBuilder<'a, Pk, Body, Unset, Path>
sourcepub fn method(
self,
method: Method
) -> VerifierBuilder<'a, Pk, Body, Method, Path>
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>
impl<'a, Pk, Body, Method> VerifierBuilder<'a, Pk, Body, Method, Unset>
source§impl<'a, Pk, Body, Method, Path> VerifierBuilder<'a, Pk, Body, Method, Path>
impl<'a, Pk, Body, Method, Path> VerifierBuilder<'a, Pk, Body, Method, Path>
sourcepub fn header(self, key: &'a str, value: &'a [u8]) -> Self
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
].
sourcepub fn headers(
self,
headers: impl IntoIterator<Item = (&'a str, &'a [u8])>
) -> Self
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())]);
sourcepub fn require_header(self, key: &'a str) -> Self
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>
impl<'a> VerifierBuilder<'a, PublicKey<'a>, &'a [u8], Method, &'a str>
sourcepub fn build_verifier(self) -> Verifier<'a>
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>
impl<'a> VerifierBuilder<'a, PublicKey<'a>, &'a [u8], Unset, Unset>
sourcepub fn build_v1_verifier(self) -> VerifierV1<'a>
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>
impl<Pk, Body, Method, Path> Debug for VerifierBuilder<'_, Pk, Body, Method, Path>
Debug does not display key info.