pub struct TokenKey(/* private fields */);Expand description
Wraps an AES-256-GCM cipher for sealing/unsealing session tokens.
Implementations§
Source§impl TokenKey
impl TokenKey
Sourcepub fn from_base64(encoded: &str) -> Result<Self, ProxyError>
pub fn from_base64(encoded: &str) -> Result<Self, ProxyError>
Create a TokenKey from a base64-encoded 32-byte key.
Sourcepub fn seal(&self, creds: &TemporaryCredentials) -> Result<String, ProxyError>
pub fn seal(&self, creds: &TemporaryCredentials) -> Result<String, ProxyError>
Encrypt TemporaryCredentials into a base64url token.
Format: base64url(nonce[12] || ciphertext+tag)
Sourcepub fn unseal(
&self,
token: &str,
) -> Result<Option<TemporaryCredentials>, ProxyError>
pub fn unseal( &self, token: &str, ) -> Result<Option<TemporaryCredentials>, ProxyError>
Decrypt a session token back into TemporaryCredentials.
Returns Ok(None) if the token doesn’t look like a sealed token
(e.g. base64 decode fails or decryption fails — allows fallback to
config-based lookup). Returns Err(ExpiredCredentials) when the
token decrypts successfully but the credentials have expired.
Trait Implementations§
Source§impl TemporaryCredentialResolver for TokenKey
impl TemporaryCredentialResolver for TokenKey
fn resolve( &self, token: &str, ) -> Result<Option<TemporaryCredentials>, ProxyError>
Auto Trait Implementations§
impl Freeze for TokenKey
impl RefUnwindSafe for TokenKey
impl Send for TokenKey
impl Sync for TokenKey
impl Unpin for TokenKey
impl UnsafeUnpin for TokenKey
impl UnwindSafe for TokenKey
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
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>
Converts
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>
Converts
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