pub struct TokenStoreFn<L, S> { /* private fields */ }Expand description
TokenStore backed by user-supplied load and save async closures.
This is the persistence layer primitive — it plugs into an existing
strategy (e.g. AccessKeyStrategy) so that
strategy can share its service-token cache across processes. For wiring
in a complete acquisition pipeline (e.g. a JS-defined strategy across
an FFI boundary), use AuthStrategyFn instead.
Closures deal in JSON strings — the on-the-wire form of Token — not
the Token type itself. This keeps the caller’s signatures free of
stack-auth internals and matches the natural shape of common storage
substrates: a cookie value, a KV blob, a Redis string.
The closure return types are generic so async blocks / async ||
closures / async fn adapters all compose without boxing.
Secret-material handling. The JSON string passed to the save
closure contains the bearer token verbatim (via
SecretToken’s #[serde(transparent)] impl). Once
the value crosses into the user’s closure, stack-auth has no control
over zeroize semantics — implementations should treat the input as
secret material and clear any local copies promptly. load wraps the
returned string in Zeroizing internally, so the buffer is wiped
after deserialisation. End-to-end protection at rest (e.g. encrypting
the value before it ever leaves the worker) is tracked as a future
EncryptedTokenStore decorator.
Implementations§
Source§impl<L, S> TokenStoreFn<L, S>
impl<L, S> TokenStoreFn<L, S>
Trait Implementations§
Source§impl<L, LF, S, SF> TokenStore for TokenStoreFn<L, S>
Available on non-WebAssembly only.
impl<L, LF, S, SF> TokenStore for TokenStoreFn<L, S>
Auto Trait Implementations§
impl<L, S> Freeze for TokenStoreFn<L, S>
impl<L, S> RefUnwindSafe for TokenStoreFn<L, S>where
L: RefUnwindSafe,
S: RefUnwindSafe,
impl<L, S> Send for TokenStoreFn<L, S>
impl<L, S> Sync for TokenStoreFn<L, S>
impl<L, S> Unpin for TokenStoreFn<L, S>
impl<L, S> UnsafeUnpin for TokenStoreFn<L, S>where
L: UnsafeUnpin,
S: UnsafeUnpin,
impl<L, S> UnwindSafe for TokenStoreFn<L, S>where
L: UnwindSafe,
S: UnwindSafe,
Blanket Implementations§
impl<T> AuthStrategyBounds for T
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> 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