pub struct TokenSigner { /* private fields */ }Expand description
Local token signer and verifier.
Implementations§
Source§impl TokenSigner
impl TokenSigner
Sourcepub fn new(signing_key: &[u8]) -> Result<Self, TokenCodecError>
pub fn new(signing_key: &[u8]) -> Result<Self, TokenCodecError>
Creates a token signer from raw key bytes.
§Errors
Returns TokenCodecError::EmptySigningKey when the signing key is empty.
Sourcepub fn sign(&self, claims: &TokenClaims) -> Result<String, TokenCodecError>
pub fn sign(&self, claims: &TokenClaims) -> Result<String, TokenCodecError>
Signs token claims into an opaque bearer token string.
§Errors
Returns TokenCodecError when the claims cannot be serialized.
Sourcepub fn verify_at(
&self,
token: &str,
current_unix_seconds: u64,
) -> Result<TokenClaims, TokenCodecError>
pub fn verify_at( &self, token: &str, current_unix_seconds: u64, ) -> Result<TokenClaims, TokenCodecError>
Verifies a token against the supplied current Unix timestamp.
§Errors
Returns TokenCodecError when the token does not parse, does not verify, or
has expired.
Sourcepub fn verify_now(&self, token: &str) -> Result<TokenClaims, TokenCodecError>
pub fn verify_now(&self, token: &str) -> Result<TokenClaims, TokenCodecError>
Verifies a token against the current wall clock.
§Errors
Returns TokenCodecError when the token is invalid or expired.
Trait Implementations§
Source§impl Clone for TokenSigner
impl Clone for TokenSigner
Source§fn clone(&self) -> TokenSigner
fn clone(&self) -> TokenSigner
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for TokenSigner
impl RefUnwindSafe for TokenSigner
impl Send for TokenSigner
impl Sync for TokenSigner
impl Unpin for TokenSigner
impl UnsafeUnpin for TokenSigner
impl UnwindSafe for TokenSigner
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