pub struct ProviderScheme {
pub signature: &'static str,
pub encoding: SignatureEncoding,
pub prefix: Option<&'static str>,
pub timestamp: Option<&'static str>,
}Expand description
A provider-specific scheme, configured rather than coded. Entries are separated by commas or spaces, so a provider may send several — for instance during a secret rotation.
Fields§
§signature: &'static strThe header carrying the signature (or several).
encoding: SignatureEncodingHow each entry is encoded in the header.
prefix: Option<&'static str>A literal prefix stripped from each entry before decoding (sha256=).
timestamp: Option<&'static str>The header carrying a Unix-seconds timestamp the provider signs.
When set, the payload is {timestamp}.{body} and the replay
tolerance applies; when None, the payload is the raw body.
Trait Implementations§
Source§impl Clone for ProviderScheme
impl Clone for ProviderScheme
impl Copy for ProviderScheme
Source§impl Debug for ProviderScheme
impl Debug for ProviderScheme
impl Eq for ProviderScheme
Source§impl PartialEq for ProviderScheme
impl PartialEq for ProviderScheme
Source§impl SignatureScheme for ProviderScheme
impl SignatureScheme for ProviderScheme
Source§fn extract(&self, headers: &HeaderMap, body: &[u8]) -> Option<SignedDelivery>
fn extract(&self, headers: &HeaderMap, body: &[u8]) -> Option<SignedDelivery>
Reads one delivery’s signature material out of the request headers
and the raw body bytes.
None on any input the scheme cannot fully
read; an empty candidate list counts as unreadable.Source§fn secret_key<'a>(&self, secret: &'a str) -> Option<Cow<'a, [u8]>>
fn secret_key<'a>(&self, secret: &'a str) -> Option<Cow<'a, [u8]>>
The key bytes the HMAC runs over: the trimmed secret’s own bytes,
unless the scheme’s providers hand out encoded secrets (Svix’s
base64
whsec_…), which decode here. None refuses.Source§fn digest(&self) -> Digest
fn digest(&self) -> Digest
The digest the scheme’s HMAC runs on. SHA-256 unless a provider
signs with SHA-1 (Vercel today). Ignored by a shared-token scheme,
which hashes nothing.
Source§fn expected_signature(&self, key: &[u8], signed_payload: &[u8]) -> Vec<u8> ⓘ
fn expected_signature(&self, key: &[u8], signed_payload: &[u8]) -> Vec<u8> ⓘ
The signature bytes a matching delivery must carry, given the
derived
key and the bytes the scheme signed. The default is
HMAC(self.digest(), key, signed_payload); a shared-token scheme
overrides this to return the key’s own bytes, because for it the
header is the secret and there is nothing to compute. Read moreimpl StructuralPartialEq for ProviderScheme
Auto Trait Implementations§
impl Freeze for ProviderScheme
impl RefUnwindSafe for ProviderScheme
impl Send for ProviderScheme
impl Sync for ProviderScheme
impl Unpin for ProviderScheme
impl UnsafeUnpin for ProviderScheme
impl UnwindSafe for ProviderScheme
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.