OAuth2SessionRepository

Trait OAuth2SessionRepository 

Source
pub trait OAuth2SessionRepository: Send + Sync {
    type Error;

Show 13 methods // Required methods fn lookup<'life0, 'async_trait>( &'life0 mut self, id: Ulid, ) -> Pin<Box<dyn Future<Output = Result<Option<Session>, Self::Error>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn add<'life0, 'life1, 'life2, 'life3, 'life4, 'life5, 'async_trait>( &'life0 mut self, rng: &'life1 mut (dyn RngCore + Send), clock: &'life2 dyn Clock, client: &'life3 Client, user: Option<&'life4 User>, user_session: Option<&'life5 BrowserSession>, scope: Scope, ) -> Pin<Box<dyn Future<Output = Result<Session, Self::Error>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait, 'life4: 'async_trait, 'life5: 'async_trait; fn finish<'life0, 'life1, 'async_trait>( &'life0 mut self, clock: &'life1 dyn Clock, session: Session, ) -> Pin<Box<dyn Future<Output = Result<Session, Self::Error>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait; fn finish_bulk<'life0, 'life1, 'life2, 'async_trait>( &'life0 mut self, clock: &'life1 dyn Clock, filter: OAuth2SessionFilter<'life2>, ) -> Pin<Box<dyn Future<Output = Result<usize, Self::Error>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait; fn list<'life0, 'life1, 'async_trait>( &'life0 mut self, filter: OAuth2SessionFilter<'life1>, pagination: Pagination, ) -> Pin<Box<dyn Future<Output = Result<Page<Session>, Self::Error>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait; fn count<'life0, 'life1, 'async_trait>( &'life0 mut self, filter: OAuth2SessionFilter<'life1>, ) -> Pin<Box<dyn Future<Output = Result<usize, Self::Error>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait; fn record_batch_activity<'life0, 'async_trait>( &'life0 mut self, activity: Vec<(Ulid, DateTime<Utc>, Option<IpAddr>)>, ) -> Pin<Box<dyn Future<Output = Result<(), Self::Error>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn record_user_agent<'life0, 'async_trait>( &'life0 mut self, session: Session, user_agent: String, ) -> Pin<Box<dyn Future<Output = Result<Session, Self::Error>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn set_human_name<'life0, 'async_trait>( &'life0 mut self, session: Session, human_name: Option<String>, ) -> Pin<Box<dyn Future<Output = Result<Session, Self::Error>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn cleanup_finished<'life0, 'async_trait>( &'life0 mut self, since: Option<DateTime<Utc>>, until: DateTime<Utc>, limit: usize, ) -> Pin<Box<dyn Future<Output = Result<(usize, Option<DateTime<Utc>>), Self::Error>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn cleanup_inactive_ips<'life0, 'async_trait>( &'life0 mut self, since: Option<DateTime<Utc>>, threshold: DateTime<Utc>, limit: usize, ) -> Pin<Box<dyn Future<Output = Result<(usize, Option<DateTime<Utc>>), Self::Error>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; // Provided methods fn add_from_browser_session<'life0, 'life1, 'life2, 'life3, 'life4, 'async_trait>( &'life0 mut self, rng: &'life1 mut (dyn RngCore + Send), clock: &'life2 dyn Clock, client: &'life3 Client, user_session: &'life4 BrowserSession, scope: Scope, ) -> Pin<Box<dyn Future<Output = Result<Session, Self::Error>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait, 'life4: 'async_trait { ... } fn add_from_client_credentials<'life0, 'life1, 'life2, 'life3, 'async_trait>( &'life0 mut self, rng: &'life1 mut (dyn RngCore + Send), clock: &'life2 dyn Clock, client: &'life3 Client, scope: Scope, ) -> Pin<Box<dyn Future<Output = Result<Session, Self::Error>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait { ... }
}
Expand description

An OAuth2SessionRepository helps interacting with [Session] saved in the storage backend

Required Associated Types§

Source

type Error

The error type returned by the repository

Required Methods§

Source

fn lookup<'life0, 'async_trait>( &'life0 mut self, id: Ulid, ) -> Pin<Box<dyn Future<Output = Result<Option<Session>, Self::Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Lookup an [Session] by its ID

Returns None if no [Session] was found

§Parameters
  • id: The ID of the [Session] to lookup
§Errors

Returns Self::Error if the underlying repository fails

Source

fn add<'life0, 'life1, 'life2, 'life3, 'life4, 'life5, 'async_trait>( &'life0 mut self, rng: &'life1 mut (dyn RngCore + Send), clock: &'life2 dyn Clock, client: &'life3 Client, user: Option<&'life4 User>, user_session: Option<&'life5 BrowserSession>, scope: Scope, ) -> Pin<Box<dyn Future<Output = Result<Session, Self::Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait, 'life4: 'async_trait, 'life5: 'async_trait,

Create a new [Session] with the given parameters

Returns the newly created [Session]

§Parameters
  • rng: The random number generator to use
  • clock: The clock used to generate timestamps
  • client: The [Client] which created the [Session]
  • user: The [User] for which the session should be created, if any
  • user_session: The [BrowserSession] of the user which completed the authorization, if any
  • scope: The [Scope] of the [Session]
§Errors

Returns Self::Error if the underlying repository fails

Source

fn finish<'life0, 'life1, 'async_trait>( &'life0 mut self, clock: &'life1 dyn Clock, session: Session, ) -> Pin<Box<dyn Future<Output = Result<Session, Self::Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Mark a [Session] as finished

Returns the updated [Session]

§Parameters
  • clock: The clock used to generate timestamps
  • session: The [Session] to mark as finished
§Errors

Returns Self::Error if the underlying repository fails

Source

fn finish_bulk<'life0, 'life1, 'life2, 'async_trait>( &'life0 mut self, clock: &'life1 dyn Clock, filter: OAuth2SessionFilter<'life2>, ) -> Pin<Box<dyn Future<Output = Result<usize, Self::Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Mark all the [Session] matching the given filter as finished

Returns the number of sessions affected

§Parameters
  • clock: The clock used to generate timestamps
  • filter: The filter parameters
§Errors

Returns Self::Error if the underlying repository fails

Source

fn list<'life0, 'life1, 'async_trait>( &'life0 mut self, filter: OAuth2SessionFilter<'life1>, pagination: Pagination, ) -> Pin<Box<dyn Future<Output = Result<Page<Session>, Self::Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

List [Session]s matching the given filter and pagination parameters

§Parameters
  • filter: The filter parameters
  • pagination: The pagination parameters
§Errors

Returns Self::Error if the underlying repository fails

Source

fn count<'life0, 'life1, 'async_trait>( &'life0 mut self, filter: OAuth2SessionFilter<'life1>, ) -> Pin<Box<dyn Future<Output = Result<usize, Self::Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Count [Session]s matching the given filter

§Parameters
  • filter: The filter parameters
§Errors

Returns Self::Error if the underlying repository fails

Source

fn record_batch_activity<'life0, 'async_trait>( &'life0 mut self, activity: Vec<(Ulid, DateTime<Utc>, Option<IpAddr>)>, ) -> Pin<Box<dyn Future<Output = Result<(), Self::Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Record a batch of [Session] activity

§Parameters
  • activity: A list of tuples containing the session ID, the last activity timestamp and the IP address of the client
§Errors

Returns Self::Error if the underlying repository fails

Source

fn record_user_agent<'life0, 'async_trait>( &'life0 mut self, session: Session, user_agent: String, ) -> Pin<Box<dyn Future<Output = Result<Session, Self::Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Record the user agent of a [Session]

§Parameters
  • session: The [Session] to record the user agent for
  • user_agent: The user agent to record
Source

fn set_human_name<'life0, 'async_trait>( &'life0 mut self, session: Session, human_name: Option<String>, ) -> Pin<Box<dyn Future<Output = Result<Session, Self::Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Set the human name of a [Session]

§Parameters
  • session: The [Session] to set the human name for
  • human_name: The human name to set
Source

fn cleanup_finished<'life0, 'async_trait>( &'life0 mut self, since: Option<DateTime<Utc>>, until: DateTime<Utc>, limit: usize, ) -> Pin<Box<dyn Future<Output = Result<(usize, Option<DateTime<Utc>>), Self::Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Cleanup finished [Session]s

Deletes sessions finished between since and until. Returns the number of deleted sessions and the timestamp of the last deleted session for pagination.

§Parameters
  • since: The earliest finish time to delete (exclusive). If None, starts from the beginning.
  • until: The latest finish time to delete (exclusive)
  • limit: Maximum number of sessions to delete in this batch
§Errors

Returns Self::Error if the underlying repository fails

Source

fn cleanup_inactive_ips<'life0, 'async_trait>( &'life0 mut self, since: Option<DateTime<Utc>>, threshold: DateTime<Utc>, limit: usize, ) -> Pin<Box<dyn Future<Output = Result<(usize, Option<DateTime<Utc>>), Self::Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Clear IP addresses from sessions inactive since the threshold

Sets last_active_ip to NULL for sessions where last_active_at is before the threshold. Returns the number of sessions affected and the last last_active_at timestamp processed for pagination.

§Parameters
  • since: Only process sessions with last_active_at at or after this timestamp (exclusive). If None, starts from the beginning.
  • threshold: Clear IPs for sessions with last_active_at before this time
  • limit: Maximum number of sessions to update in this batch
§Errors

Returns Self::Error if the underlying repository fails

Provided Methods§

Source

fn add_from_browser_session<'life0, 'life1, 'life2, 'life3, 'life4, 'async_trait>( &'life0 mut self, rng: &'life1 mut (dyn RngCore + Send), clock: &'life2 dyn Clock, client: &'life3 Client, user_session: &'life4 BrowserSession, scope: Scope, ) -> Pin<Box<dyn Future<Output = Result<Session, Self::Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait, 'life4: 'async_trait,

Create a new [Session] out of a [Client] and a [BrowserSession]

Returns the newly created [Session]

§Parameters
  • rng: The random number generator to use
  • clock: The clock used to generate timestamps
  • client: The [Client] which created the [Session]
  • user_session: The [BrowserSession] of the user which completed the authorization
  • scope: The [Scope] of the [Session]
§Errors

Returns Self::Error if the underlying repository fails

Source

fn add_from_client_credentials<'life0, 'life1, 'life2, 'life3, 'async_trait>( &'life0 mut self, rng: &'life1 mut (dyn RngCore + Send), clock: &'life2 dyn Clock, client: &'life3 Client, scope: Scope, ) -> Pin<Box<dyn Future<Output = Result<Session, Self::Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait,

Create a new [Session] for a [Client] using the client credentials flow

Returns the newly created [Session]

§Parameters
  • rng: The random number generator to use
  • clock: The clock used to generate timestamps
  • client: The [Client] which created the [Session]
  • scope: The [Scope] of the [Session]
§Errors

Returns Self::Error if the underlying repository fails

Implementations on Foreign Types§

Source§

impl<R> OAuth2SessionRepository for Box<R>

Source§

type Error = <R as OAuth2SessionRepository>::Error

Source§

fn lookup<'life0, 'async_trait>( &'life0 mut self, id: Ulid, ) -> Pin<Box<dyn Future<Output = Result<Option<Session>, Self::Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Source§

fn add<'life0, 'life1, 'life2, 'life3, 'life4, 'life5, 'async_trait>( &'life0 mut self, rng: &'life1 mut (dyn RngCore + Send), clock: &'life2 dyn Clock, client: &'life3 Client, user: Option<&'life4 User>, user_session: Option<&'life5 BrowserSession>, scope: Scope, ) -> Pin<Box<dyn Future<Output = Result<Session, Self::Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait, 'life4: 'async_trait, 'life5: 'async_trait,

Source§

fn add_from_browser_session<'life0, 'life1, 'life2, 'life3, 'life4, 'async_trait>( &'life0 mut self, rng: &'life1 mut (dyn RngCore + Send), clock: &'life2 dyn Clock, client: &'life3 Client, user_session: &'life4 BrowserSession, scope: Scope, ) -> Pin<Box<dyn Future<Output = Result<Session, Self::Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait, 'life4: 'async_trait,

Source§

fn add_from_client_credentials<'life0, 'life1, 'life2, 'life3, 'async_trait>( &'life0 mut self, rng: &'life1 mut (dyn RngCore + Send), clock: &'life2 dyn Clock, client: &'life3 Client, scope: Scope, ) -> Pin<Box<dyn Future<Output = Result<Session, Self::Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait,

Source§

fn finish<'life0, 'life1, 'async_trait>( &'life0 mut self, clock: &'life1 dyn Clock, session: Session, ) -> Pin<Box<dyn Future<Output = Result<Session, Self::Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Source§

fn finish_bulk<'life0, 'life1, 'life2, 'async_trait>( &'life0 mut self, clock: &'life1 dyn Clock, filter: OAuth2SessionFilter<'life2>, ) -> Pin<Box<dyn Future<Output = Result<usize, Self::Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Source§

fn list<'life0, 'life1, 'async_trait>( &'life0 mut self, filter: OAuth2SessionFilter<'life1>, pagination: Pagination, ) -> Pin<Box<dyn Future<Output = Result<Page<Session>, Self::Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Source§

fn count<'life0, 'life1, 'async_trait>( &'life0 mut self, filter: OAuth2SessionFilter<'life1>, ) -> Pin<Box<dyn Future<Output = Result<usize, Self::Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Source§

fn record_batch_activity<'life0, 'async_trait>( &'life0 mut self, activity: Vec<(Ulid, DateTime<Utc>, Option<IpAddr>)>, ) -> Pin<Box<dyn Future<Output = Result<(), Self::Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Source§

fn record_user_agent<'life0, 'async_trait>( &'life0 mut self, session: Session, user_agent: String, ) -> Pin<Box<dyn Future<Output = Result<Session, Self::Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Source§

fn set_human_name<'life0, 'async_trait>( &'life0 mut self, session: Session, human_name: Option<String>, ) -> Pin<Box<dyn Future<Output = Result<Session, Self::Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Source§

fn cleanup_finished<'life0, 'async_trait>( &'life0 mut self, since: Option<DateTime<Utc>>, until: DateTime<Utc>, limit: usize, ) -> Pin<Box<dyn Future<Output = Result<(usize, Option<DateTime<Utc>>), Self::Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Source§

fn cleanup_inactive_ips<'life0, 'async_trait>( &'life0 mut self, since: Option<DateTime<Utc>>, threshold: DateTime<Utc>, limit: usize, ) -> Pin<Box<dyn Future<Output = Result<(usize, Option<DateTime<Utc>>), Self::Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Implementors§