pub struct OAuthStateStore { /* private fields */ }Expand description
Stores OAuth state parameters to prevent CSRF attacks on the callback.
State tokens are short-lived (10 minutes) and single-use. Backed by an
OAuthStateBackend; defaults to in-memory but the runtime persists them
to SQLite (or Postgres when DATABASE_URL is set) so they survive a
restart that happens mid-OAuth-handshake.
Implementations§
Source§impl OAuthStateStore
impl OAuthStateStore
pub fn new() -> Self
pub fn with_backend(backend: Box<dyn OAuthStateBackend>) -> Self
Sourcepub fn create(
&self,
provider: &str,
callback_url: &str,
error_callback_url: &str,
) -> String
pub fn create( &self, provider: &str, callback_url: &str, error_callback_url: &str, ) -> String
Generate and store a new state record. Returns the random
state token (the value the OAuth provider echoes back as
?state=… on the callback).
Caller is responsible for validating callback_url and
error_callback_url against the trusted-origins allowlist
BEFORE calling this — the store trusts what it’s given.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for OAuthStateStore
impl !RefUnwindSafe for OAuthStateStore
impl Send for OAuthStateStore
impl Sync for OAuthStateStore
impl Unpin for OAuthStateStore
impl UnsafeUnpin for OAuthStateStore
impl !UnwindSafe for OAuthStateStore
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