Trait mas_storage::user::BrowserSessionRepository

source ·
pub trait BrowserSessionRepository: Send + Sync {
    type Error;

    // Required methods
    fn lookup<'life0, 'async_trait>(
        &'life0 mut self,
        id: Ulid,
    ) -> Pin<Box<dyn Future<Output = Result<Option<BrowserSession>, Self::Error>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn add<'life0, 'life1, 'life2, 'life3, 'async_trait>(
        &'life0 mut self,
        rng: &'life1 mut (dyn RngCore + Send),
        clock: &'life2 dyn Clock,
        user: &'life3 User,
        user_agent: Option<UserAgent>,
    ) -> Pin<Box<dyn Future<Output = Result<BrowserSession, Self::Error>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait,
             'life3: 'async_trait;
    fn finish<'life0, 'life1, 'async_trait>(
        &'life0 mut self,
        clock: &'life1 dyn Clock,
        user_session: BrowserSession,
    ) -> Pin<Box<dyn Future<Output = Result<BrowserSession, 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: BrowserSessionFilter<'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: BrowserSessionFilter<'life1>,
        pagination: Pagination,
    ) -> Pin<Box<dyn Future<Output = Result<Page<BrowserSession>, 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: BrowserSessionFilter<'life1>,
    ) -> Pin<Box<dyn Future<Output = Result<usize, Self::Error>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn authenticate_with_password<'life0, 'life1, 'life2, 'life3, 'life4, 'async_trait>(
        &'life0 mut self,
        rng: &'life1 mut (dyn RngCore + Send),
        clock: &'life2 dyn Clock,
        user_session: &'life3 BrowserSession,
        user_password: &'life4 Password,
    ) -> Pin<Box<dyn Future<Output = Result<Authentication, 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 authenticate_with_upstream<'life0, 'life1, 'life2, 'life3, 'life4, 'async_trait>(
        &'life0 mut self,
        rng: &'life1 mut (dyn RngCore + Send),
        clock: &'life2 dyn Clock,
        user_session: &'life3 BrowserSession,
        upstream_oauth_session: &'life4 UpstreamOAuthAuthorizationSession,
    ) -> Pin<Box<dyn Future<Output = Result<Authentication, 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 get_last_authentication<'life0, 'life1, 'async_trait>(
        &'life0 mut self,
        user_session: &'life1 BrowserSession,
    ) -> Pin<Box<dyn Future<Output = Result<Option<Authentication>, 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;
}
Expand description

A BrowserSessionRepository helps interacting with [BrowserSession] 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<BrowserSession>, Self::Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Lookup a [BrowserSession] by its ID

Returns None if the session is not 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, 'async_trait>( &'life0 mut self, rng: &'life1 mut (dyn RngCore + Send), clock: &'life2 dyn Clock, user: &'life3 User, user_agent: Option<UserAgent>, ) -> Pin<Box<dyn Future<Output = Result<BrowserSession, Self::Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait,

Create a new [BrowserSession] for a [User]

Returns the newly created [BrowserSession]

§Parameters
  • rng: The random number generator to use
  • clock: The clock used to generate timestamps
  • user: The user to create the session for
  • user_agent: If available, the user agent of the browser
§Errors

Returns Self::Error if the underlying repository fails

source

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

Finish a [BrowserSession]

Returns the finished session

§Parameters
  • clock: The clock used to generate timestamps
  • user_session: The session to finish
§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: BrowserSessionFilter<'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 [BrowserSession] 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: BrowserSessionFilter<'life1>, pagination: Pagination, ) -> Pin<Box<dyn Future<Output = Result<Page<BrowserSession>, Self::Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

List [BrowserSession] with the given filter and pagination

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

Returns Self::Error if the underlying repository fails

source

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

Count the number of [BrowserSession] with the given filter

§Parameters
  • filter: The filter to apply
§Errors

Returns Self::Error if the underlying repository fails

source

fn authenticate_with_password<'life0, 'life1, 'life2, 'life3, 'life4, 'async_trait>( &'life0 mut self, rng: &'life1 mut (dyn RngCore + Send), clock: &'life2 dyn Clock, user_session: &'life3 BrowserSession, user_password: &'life4 Password, ) -> Pin<Box<dyn Future<Output = Result<Authentication, Self::Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait, 'life4: 'async_trait,

Authenticate a [BrowserSession] with the given [Password]

§Parameters
  • rng: The random number generator to use
  • clock: The clock used to generate timestamps
  • user_session: The session to authenticate
  • user_password: The password which was used to authenticate
§Errors

Returns Self::Error if the underlying repository fails

source

fn authenticate_with_upstream<'life0, 'life1, 'life2, 'life3, 'life4, 'async_trait>( &'life0 mut self, rng: &'life1 mut (dyn RngCore + Send), clock: &'life2 dyn Clock, user_session: &'life3 BrowserSession, upstream_oauth_session: &'life4 UpstreamOAuthAuthorizationSession, ) -> Pin<Box<dyn Future<Output = Result<Authentication, Self::Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait, 'life4: 'async_trait,

Authenticate a [BrowserSession] with the given [UpstreamOAuthAuthorizationSession]

§Parameters
  • rng: The random number generator to use
  • clock: The clock used to generate timestamps
  • user_session: The session to authenticate
  • upstream_oauth_session: The upstream OAuth session which was used to authenticate
§Errors

Returns Self::Error if the underlying repository fails

source

fn get_last_authentication<'life0, 'life1, 'async_trait>( &'life0 mut self, user_session: &'life1 BrowserSession, ) -> Pin<Box<dyn Future<Output = Result<Option<Authentication>, Self::Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Get the last successful authentication for a [BrowserSession]

§Params
  • user_session: The session for which to get the last authentication
§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 [BrowserSession] 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

Implementations on Foreign Types§

source§

impl<R> BrowserSessionRepository for Box<R>

§

type Error = <R as BrowserSessionRepository>::Error

source§

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

source§

fn add<'life0, 'life1, 'life2, 'life3, 'async_trait>( &'life0 mut self, rng: &'life1 mut (dyn RngCore + Send), clock: &'life2 dyn Clock, user: &'life3 User, user_agent: Option<UserAgent>, ) -> Pin<Box<dyn Future<Output = Result<BrowserSession, 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, user_session: BrowserSession, ) -> Pin<Box<dyn Future<Output = Result<BrowserSession, 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: BrowserSessionFilter<'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: BrowserSessionFilter<'life1>, pagination: Pagination, ) -> Pin<Box<dyn Future<Output = Result<Page<BrowserSession>, 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: BrowserSessionFilter<'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 authenticate_with_password<'life0, 'life1, 'life2, 'life3, 'life4, 'async_trait>( &'life0 mut self, rng: &'life1 mut (dyn RngCore + Send), clock: &'life2 dyn Clock, user_session: &'life3 BrowserSession, user_password: &'life4 Password, ) -> Pin<Box<dyn Future<Output = Result<Authentication, 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 authenticate_with_upstream<'life0, 'life1, 'life2, 'life3, 'life4, 'async_trait>( &'life0 mut self, rng: &'life1 mut (dyn RngCore + Send), clock: &'life2 dyn Clock, user_session: &'life3 BrowserSession, upstream_oauth_session: &'life4 UpstreamOAuthAuthorizationSession, ) -> Pin<Box<dyn Future<Output = Result<Authentication, 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 get_last_authentication<'life0, 'life1, 'async_trait>( &'life0 mut self, user_session: &'life1 BrowserSession, ) -> Pin<Box<dyn Future<Output = Result<Option<Authentication>, 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,

Implementors§