Skip to main content

OAuthStateBackend

Trait OAuthStateBackend 

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

Backing store for OAuth state records. Default impl keeps them in memory (fine for tests + dev); the runtime swaps in a SQLite or Postgres backend so a restart in the middle of an OAuth handshake doesn’t leave the user with “invalid state” on the callback.

Required Methods§

Source

fn put(&self, token: &str, state: &OAuthState)

Persist a state record under token.

Source

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

Atomic compare-and-consume: returns the stored record 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 / expired.

Implementors§