pub struct SignedUrlVerifier { /* private fields */ }Expand description
A signed URL verifier (DW-109).
Built from a route’s SignedUrlConfig at snapshot compile time.
The verifier holds the HMAC secret and the query parameter name.
The SignedUrlVerifier::verify method extracts the signature
and expiry from the query string, recomputes the HMAC, and checks
the expiry.
Implementations§
Source§impl SignedUrlVerifier
impl SignedUrlVerifier
Sourcepub fn from_config(config: &SignedUrlConfig) -> Result<Self, SignedUrlError>
pub fn from_config(config: &SignedUrlConfig) -> Result<Self, SignedUrlError>
Build a verifier from a SignedUrlConfig. Returns an error
if the config is invalid (empty secret, empty query_param).
Sourcepub fn query_param(&self) -> &str
pub fn query_param(&self) -> &str
The query parameter name this verifier looks for.
Sourcepub fn verify(
&self,
method: &str,
path: &str,
query: &str,
now: u64,
client_ip: &str,
) -> SignedUrlResult
pub fn verify( &self, method: &str, path: &str, query: &str, now: u64, client_ip: &str, ) -> SignedUrlResult
Verify a signed URL request. Extracts the signature and expiry from the query string, recomputes the HMAC-SHA256 over the canonical request (method, path, expires), and checks the expiry.
method: the uppercase HTTP method (e.g. “GET”).path: the request path (without query string).query: the raw query string (e.g. “foo=bar&sig=abc&expires=123”).now: the current Unix epoch seconds.client_ip: the client’s IP address (used whenbind_client_ipis true; pass an empty string to skip).
Returns SignedUrlResult::Valid if the signature matches
and the URL has not expired; SignedUrlResult::Invalid if
the signature is missing or does not match; SignedUrlResult::Expired
if the URL has expired; SignedUrlResult::NonceError if the
nonce is missing or replayed (SEC-07, #211).
Sourcepub fn sign(
&self,
method: &str,
path: &str,
expires: u64,
client_ip: &str,
nonce: Option<&str>,
) -> Result<String, SignedUrlError>
pub fn sign( &self, method: &str, path: &str, expires: u64, client_ip: &str, nonce: Option<&str>, ) -> Result<String, SignedUrlError>
Mint a signed URL query string for the given request. This is
the counterpart to verify: an external URL
minter (or a test) uses it to produce a valid signature.
method: the uppercase HTTP method.path: the request path (without query string).expires: the Unix epoch seconds at which the URL expires.client_ip: the client’s IP address (used whenbind_client_ipis true; pass an empty string to skip).nonce: an optional nonce (used whenrequire_nonceis true; the caller generates a unique nonce per URL).
Returns the query string with the signature, expiry, and optional nonce parameters.
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for SignedUrlVerifier
impl RefUnwindSafe for SignedUrlVerifier
impl Send for SignedUrlVerifier
impl Sync for SignedUrlVerifier
impl Unpin for SignedUrlVerifier
impl UnwindSafe for SignedUrlVerifier
Blanket Implementations§
§impl<T> AnyExt for T
impl<T> AnyExt for T
§fn downcast_ref<T>(this: &Self) -> Option<&T>where
T: Any,
fn downcast_ref<T>(this: &Self) -> Option<&T>where
T: Any,
T behind reference§fn downcast_mut<T>(this: &mut Self) -> Option<&mut T>where
T: Any,
fn downcast_mut<T>(this: &mut Self) -> Option<&mut T>where
T: Any,
T behind mutable reference§fn downcast_rc<T>(this: Rc<Self>) -> Result<Rc<T>, Rc<Self>>where
T: Any,
fn downcast_rc<T>(this: Rc<Self>) -> Result<Rc<T>, Rc<Self>>where
T: Any,
T behind Rc pointer§fn downcast_arc<T>(this: Arc<Self>) -> Result<Arc<T>, Arc<Self>>where
T: Any,
fn downcast_arc<T>(this: Arc<Self>) -> Result<Arc<T>, Arc<Self>>where
T: Any,
T behind Arc pointer§fn downcast_box<T>(this: Box<Self>) -> Result<Box<T>, Box<Self>>where
T: Any,
fn downcast_box<T>(this: Box<Self>) -> Result<Box<T>, Box<Self>>where
T: Any,
T behind Box pointer§fn downcast_move<T>(this: Self) -> Option<T>
fn downcast_move<T>(this: Self) -> Option<T>
Self to T,
useful only in generic context as a workaround for specializationSource§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
§impl<T, X> CoerceTo<T> for Xwhere
T: CoerceFrom<X> + ?Sized,
impl<T, X> CoerceTo<T> for Xwhere
T: CoerceFrom<X> + ?Sized,
fn coerce_rc_to(self: Rc<X>) -> Rc<T>
fn coerce_box_to(self: Box<X>) -> Box<T>
fn coerce_ref_to(&self) -> &T
fn coerce_mut_to(&mut self) -> &mut T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more