pub struct UrlSigner { /* private fields */ }Expand description
Signs and verifies URLs with a key derived from APP_KEY.
Implementations§
Source§impl UrlSigner
impl UrlSigner
pub fn new(key: &AppKey) -> Self
pub fn from_config(config: &Config) -> Result<Self>
Sourcepub fn sign(&self, url: &str, expires_at: Option<u64>) -> String
pub fn sign(&self, url: &str, expires_at: Option<u64>) -> String
Sign a URL, optionally giving it an expiry.
expires_at is a unix timestamp in seconds; None signs a link that
never expires, which is right for an unsubscribe URL and wrong for a
password reset. Any signature or expires already on the URL is
dropped first, so re-signing a link is idempotent rather than
accumulating parameters.
Sourcepub fn sign_temporary(&self, url: &str, ttl: Duration) -> String
pub fn sign_temporary(&self, url: &str, ttl: Duration) -> String
Sign a URL that expires ttl from now — the common case.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for UrlSigner
impl RefUnwindSafe for UrlSigner
impl Send for UrlSigner
impl Sync for UrlSigner
impl Unpin for UrlSigner
impl UnsafeUnpin for UrlSigner
impl UnwindSafe for UrlSigner
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