pub struct AuthStrategyFn<F> { /* private fields */ }Expand description
AuthStrategy backed by a user-supplied async closure that returns
a ServiceToken.
§Example
use stack_auth::{AuthError, AuthStrategyFn, SecretToken, ServiceToken};
let strategy = AuthStrategyFn::new(|| async {
// Real consumers would call into FFI / IPC / a cached token store.
Ok::<_, AuthError>(ServiceToken::new(SecretToken::new("dummy.jwt.value".to_string())))
});§When to reach for this vs TokenStoreFn
AuthStrategyFn: you control the entire token pipeline — fetch, refresh, cache.cipherstash-clientcalls your closure and uses whatever it returns, no further questions asked. Used by FFI bindings that proxy to a JS-side strategy doing all the work upstream.TokenStoreFn: you want stack-auth’sAccessKeyStrategy(or another concrete strategy) to do the HTTP/refresh work, and you just want to plug in custom persistence (a cookie, a KV blob, Redis).
Implementations§
Source§impl<F> AuthStrategyFn<F>
impl<F> AuthStrategyFn<F>
Sourcepub fn new(get_token: F) -> Self
pub fn new(get_token: F) -> Self
Build an AuthStrategyFn from an async closure. The closure fires
every time AuthStrategy::get_token is called on a reference to
this strategy — typically once per cipherstash-client HTTP request,
modulo any in-process caching the closure does internally.
Trait Implementations§
Source§impl<F, Fut> AuthStrategy for &AuthStrategyFn<F>
Available on non-WebAssembly only.
impl<F, Fut> AuthStrategy for &AuthStrategyFn<F>
Available on non-WebAssembly only.
Auto Trait Implementations§
impl<F> Freeze for AuthStrategyFn<F>where
F: Freeze,
impl<F> RefUnwindSafe for AuthStrategyFn<F>where
F: RefUnwindSafe,
impl<F> Send for AuthStrategyFn<F>where
F: Send,
impl<F> Sync for AuthStrategyFn<F>where
F: Sync,
impl<F> Unpin for AuthStrategyFn<F>where
F: Unpin,
impl<F> UnsafeUnpin for AuthStrategyFn<F>where
F: UnsafeUnpin,
impl<F> UnwindSafe for AuthStrategyFn<F>where
F: 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
Mutably borrows from an owned value. Read more
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