Skip to main content

OAuthStore

Trait OAuthStore 

Source
pub trait OAuthStore:
    Send
    + Sync
    + 'static {
    // Required methods
    fn insert_state(
        &self,
        state: String,
        entry: StoredStateEntry,
        ttl: Duration,
    ) -> impl Future<Output = Result<(), StoreError>> + Send;
    fn take_state(
        &self,
        state: &str,
    ) -> impl Future<Output = Result<Option<StoredStateEntry>, StoreError>> + Send;
    fn contains_state(
        &self,
        state: &str,
    ) -> impl Future<Output = Result<bool, StoreError>> + Send;
    fn prune_expired(
        &self,
    ) -> impl Future<Output = Result<usize, StoreError>> + Send;
}
Expand description

Asynchronous, zero-cost storage abstraction for AT Protocol OAuth state and sessions.

Implemented by OAuthStateStore for high-performance in-memory storage, and can be implemented by external crates for Redis, SQL, or distributed backends.

Required Methods§

Source

fn insert_state( &self, state: String, entry: StoredStateEntry, ttl: Duration, ) -> impl Future<Output = Result<(), StoreError>> + Send

Inserts a temporary authorization state entry with a specified TTL.

§Errors

Returns StoreError if the underlying storage backend fails.

Source

fn take_state( &self, state: &str, ) -> impl Future<Output = Result<Option<StoredStateEntry>, StoreError>> + Send

Atomically takes and removes an authorization state entry by state token.

Single-use semantics: If the state is found and has not expired, it is returned and immediately removed from storage. Subsequent lookups with the same token will return Ok(None).

§Errors

Returns StoreError if the underlying storage backend fails.

Source

fn contains_state( &self, state: &str, ) -> impl Future<Output = Result<bool, StoreError>> + Send

Checks whether an active, unexpired state entry exists without consuming it.

§Errors

Returns StoreError if the underlying storage backend fails.

Source

fn prune_expired( &self, ) -> impl Future<Output = Result<usize, StoreError>> + Send

Prunes all expired state entries across the store, returning the number of evicted entries.

§Errors

Returns StoreError if the underlying storage backend fails.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§