pub struct TicketSigner { /* private fields */ }Expand description
Signs and verifies read-tickets using an ephemeral 256-bit HMAC key.
Create one instance per process lifetime via TicketSigner::new.
Implementations§
Source§impl TicketSigner
impl TicketSigner
Sourcepub fn new() -> Self
pub fn new() -> Self
Creates a new signer with a cryptographically random key.
§Panics
Panics if the OS CSPRNG is unavailable — an unrecoverable situation.
Sourcepub fn issue(&self, path: &str, content_sha256: &str, ttl_secs: u64) -> String
pub fn issue(&self, path: &str, content_sha256: &str, ttl_secs: u64) -> String
Issues a ticket for path + content_sha256 that expires after ttl_secs seconds.
Returns the opaque ticket string "rt2.{exp}.{content_sha256}.{hmac_hex}".
Sourcepub fn verify(
&self,
ticket: &str,
expected_path: &str,
) -> Result<TicketClaims, TicketError>
pub fn verify( &self, ticket: &str, expected_path: &str, ) -> Result<TicketClaims, TicketError>
Verifies that ticket was issued for expected_path and has not expired.
Returns parsed claims on success, or a TicketError describing the failure.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for TicketSigner
impl RefUnwindSafe for TicketSigner
impl Send for TicketSigner
impl Sync for TicketSigner
impl Unpin for TicketSigner
impl UnsafeUnpin for TicketSigner
impl UnwindSafe for TicketSigner
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