pub struct SignedUrlAuth { /* private fields */ }Expand description
Signed URL authenticator using HMAC-SHA256.
This struct provides methods for generating and verifying signed URLs. The signing scheme binds signatures to paths, query params, and expiry times.
Implementations§
Source§impl SignedUrlAuth
impl SignedUrlAuth
Sourcepub fn new(secret_key: impl AsRef<[u8]>) -> Self
pub fn new(secret_key: impl AsRef<[u8]>) -> Self
Create a new authenticator with the given secret key.
§Arguments
secret_key- The secret key used for HMAC computation. Should be at least 32 bytes for security.
Sourcepub fn sign_with_params(
&self,
path: &str,
ttl: Duration,
params: &[(&str, &str)],
) -> (String, u64)
pub fn sign_with_params( &self, path: &str, ttl: Duration, params: &[(&str, &str)], ) -> (String, u64)
Sign a path with extra query parameters.
params should exclude exp and sig; those are added automatically.
Sourcepub fn sign_with_expiry(&self, path: &str, expiry: u64) -> String
pub fn sign_with_expiry(&self, path: &str, expiry: u64) -> String
Sourcepub fn sign_with_expiry_and_params(
&self,
path: &str,
expiry: u64,
params: &[(&str, &str)],
) -> String
pub fn sign_with_expiry_and_params( &self, path: &str, expiry: u64, params: &[(&str, &str)], ) -> String
Sign a path with a specific expiry timestamp and extra parameters.
params should exclude exp and sig; those are added automatically.
Sourcepub fn verify(
&self,
path: &str,
signature: &str,
expiry: u64,
params: &[(&str, &str)],
) -> Result<(), AuthError>
pub fn verify( &self, path: &str, signature: &str, expiry: u64, params: &[(&str, &str)], ) -> Result<(), AuthError>
Sourcepub fn generate_signed_url(
&self,
base_url: &str,
path: &str,
ttl: Duration,
extra_params: &[(&str, &str)],
) -> String
pub fn generate_signed_url( &self, base_url: &str, path: &str, ttl: Duration, extra_params: &[(&str, &str)], ) -> String
Sourcepub fn generate_viewer_token(
&self,
slide_id: &str,
ttl: Duration,
) -> (String, u64)
pub fn generate_viewer_token( &self, slide_id: &str, ttl: Duration, ) -> (String, u64)
Generate a viewer token for accessing all tiles of a specific slide.
Viewer tokens are special tokens that authorize access to all tiles for a given slide, rather than signing individual tile paths. This is used by the built-in viewer to access tiles when auth is enabled.
§Arguments
slide_id- The slide identifierttl- How long the token should be valid
§Returns
A tuple of (token, expiry_timestamp)
Trait Implementations§
Source§impl Clone for SignedUrlAuth
impl Clone for SignedUrlAuth
Source§fn clone(&self) -> SignedUrlAuth
fn clone(&self) -> SignedUrlAuth
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for SignedUrlAuth
impl RefUnwindSafe for SignedUrlAuth
impl Send for SignedUrlAuth
impl Sync for SignedUrlAuth
impl Unpin for SignedUrlAuth
impl UnwindSafe for SignedUrlAuth
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§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