CompatRefreshTokenRepository

Trait CompatRefreshTokenRepository 

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

    // Required methods
    fn lookup<'life0, 'async_trait>(
        &'life0 mut self,
        id: Ulid,
    ) -> Pin<Box<dyn Future<Output = Result<Option<CompatRefreshToken>, Self::Error>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn find_by_token<'life0, 'life1, 'async_trait>(
        &'life0 mut self,
        refresh_token: &'life1 str,
    ) -> Pin<Box<dyn Future<Output = Result<Option<CompatRefreshToken>, Self::Error>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn add<'life0, 'life1, 'life2, 'life3, 'life4, 'async_trait>(
        &'life0 mut self,
        rng: &'life1 mut (dyn RngCore + Send),
        clock: &'life2 dyn Clock,
        compat_session: &'life3 CompatSession,
        compat_access_token: &'life4 CompatAccessToken,
        token: String,
    ) -> Pin<Box<dyn Future<Output = Result<CompatRefreshToken, 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 consume_and_replace<'life0, 'life1, 'life2, 'async_trait>(
        &'life0 mut self,
        clock: &'life1 dyn Clock,
        compat_refresh_token: CompatRefreshToken,
        successor_compat_refresh_token: &'life2 CompatRefreshToken,
    ) -> Pin<Box<dyn Future<Output = Result<CompatRefreshToken, Self::Error>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait;
}
Expand description

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

Lookup a compat refresh token by its ID

Returns the compat refresh token if it exists, None otherwise

§Parameters
  • id: The ID of the compat refresh token to lookup
§Errors

Returns Self::Error if the underlying repository fails

Source

fn find_by_token<'life0, 'life1, 'async_trait>( &'life0 mut self, refresh_token: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<Option<CompatRefreshToken>, Self::Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Find a compat refresh token by its token

Returns the compat refresh token if found, None otherwise

§Parameters
  • refresh_token: The token of the compat refresh token to lookup
§Errors

Returns Self::Error if the underlying repository fails

Source

fn add<'life0, 'life1, 'life2, 'life3, 'life4, 'async_trait>( &'life0 mut self, rng: &'life1 mut (dyn RngCore + Send), clock: &'life2 dyn Clock, compat_session: &'life3 CompatSession, compat_access_token: &'life4 CompatAccessToken, token: String, ) -> Pin<Box<dyn Future<Output = Result<CompatRefreshToken, Self::Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait, 'life4: 'async_trait,

Add a new compat refresh token to the database

Returns the newly created compat refresh token

§Parameters
  • rng: The random number generator to use
  • clock: The clock used to generate timestamps
  • compat_session: The compat session associated with this refresh token
  • compat_access_token: The compat access token created alongside this refresh token
  • token: The token of the refresh token
Source

fn consume_and_replace<'life0, 'life1, 'life2, 'async_trait>( &'life0 mut self, clock: &'life1 dyn Clock, compat_refresh_token: CompatRefreshToken, successor_compat_refresh_token: &'life2 CompatRefreshToken, ) -> Pin<Box<dyn Future<Output = Result<CompatRefreshToken, Self::Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Consume the given compat refresh token, as well as all other refresh tokens from the same session, except for the given successor compat refresh token.

The given successor refresh token will thereafter be the only valid refresh token for the session.

§Historical context

When using a refresh token, we must be able to mark multiple other refresh tokens in the same session as consumed. This is desirable because the syn2mas migration process can import multiple refresh tokens for one device (compat session). But once the user uses one of those, the others should no longer be valid.

§Parameters
  • clock: The clock used to generate timestamps
  • compat_refresh_token: The compat refresh token to consume
§Errors
  • Returns Self::Error if the underlying repository fails
  • Returns an error if compat_refresh_token is not valid to be consumed.
  • Returns an error if no refresh tokens would be consumed.

Implementations on Foreign Types§

Source§

impl<R> CompatRefreshTokenRepository for Box<R>

Source§

type Error = <R as CompatRefreshTokenRepository>::Error

Source§

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

Source§

fn find_by_token<'life0, 'life1, 'async_trait>( &'life0 mut self, refresh_token: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<Option<CompatRefreshToken>, Self::Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Source§

fn add<'life0, 'life1, 'life2, 'life3, 'life4, 'async_trait>( &'life0 mut self, rng: &'life1 mut (dyn RngCore + Send), clock: &'life2 dyn Clock, compat_session: &'life3 CompatSession, compat_access_token: &'life4 CompatAccessToken, token: String, ) -> Pin<Box<dyn Future<Output = Result<CompatRefreshToken, 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 consume_and_replace<'life0, 'life1, 'life2, 'async_trait>( &'life0 mut self, clock: &'life1 dyn Clock, compat_refresh_token: CompatRefreshToken, successor_compat_refresh_token: &'life2 CompatRefreshToken, ) -> Pin<Box<dyn Future<Output = Result<CompatRefreshToken, Self::Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Implementors§