Skip to main content

OAuthStateBackend

Trait OAuthStateBackend 

Source
pub trait OAuthStateBackend: Send + Sync {
    // Required methods
    fn put(&self, token: &str, provider: &str, expires_at: u64);
    fn take(&self, token: &str, now_unix_secs: u64) -> Option<String>;
}
Expand description

Backing store for OAuth state tokens. Default impl keeps them in memory (fine for tests + dev); the runtime swaps in a SQLite-backed impl so a restart in the middle of an OAuth handshake doesn’t leave the user with “invalid state” on the callback. Same pattern as SessionBackend.

Required Methods§

Source

fn put(&self, token: &str, provider: &str, expires_at: u64)

Source

fn take(&self, token: &str, now_unix_secs: u64) -> Option<String>

Atomic compare-and-consume: returns the stored provider if the token exists and hasn’t expired, then removes it. Returning None means either the token never existed or it has already been used.

Implementors§