pub trait OAuth2RefreshTokenRepository: Send + Sync {
    type Error;

    // Required methods
    fn lookup<'life0, 'async_trait>(
        &'life0 mut self,
        id: Ulid,
    ) -> Pin<Box<dyn Future<Output = Result<Option<RefreshToken>, 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<RefreshToken>, 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,
        session: &'life3 Session,
        access_token: &'life4 AccessToken,
        refresh_token: String,
    ) -> Pin<Box<dyn Future<Output = Result<RefreshToken, 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<'life0, 'life1, 'async_trait>(
        &'life0 mut self,
        clock: &'life1 dyn Clock,
        refresh_token: RefreshToken,
    ) -> Pin<Box<dyn Future<Output = Result<RefreshToken, Self::Error>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
}
Expand description

An OAuth2RefreshTokenRepository helps interacting with [RefreshToken] 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<RefreshToken>, Self::Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Lookup a refresh token by its ID

Returns None if no [RefreshToken] was found

§Parameters
  • id: The ID of the [RefreshToken] 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<RefreshToken>, Self::Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Find a refresh token by its token

Returns None if no [RefreshToken] was found

§Parameters
  • token: The token of the [RefreshToken] 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, session: &'life3 Session, access_token: &'life4 AccessToken, refresh_token: String, ) -> Pin<Box<dyn Future<Output = Result<RefreshToken, 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 refresh token to the database

Returns the newly created [RefreshToken]

§Parameters
  • rng: The random number generator to use
  • clock: The clock used to generate timestamps
  • session: The [Session] in which to create the [RefreshToken]
  • access_token: The [AccessToken] created alongside this [RefreshToken]
  • refresh_token: The refresh token to store
§Errors

Returns Self::Error if the underlying repository fails

source

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

Consume a refresh token

Returns the updated [RefreshToken]

§Parameters
  • clock: The clock used to generate timestamps
  • refresh_token: The [RefreshToken] to consume
§Errors

Returns Self::Error if the underlying repository fails, or if the token was already consumed

Implementations on Foreign Types§

source§

impl<R> OAuth2RefreshTokenRepository for Box<R>

§

type Error = <R as OAuth2RefreshTokenRepository>::Error

source§

fn lookup<'life0, 'async_trait>( &'life0 mut self, id: Ulid, ) -> Pin<Box<dyn Future<Output = Result<Option<RefreshToken>, 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<RefreshToken>, 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, session: &'life3 Session, access_token: &'life4 AccessToken, refresh_token: String, ) -> Pin<Box<dyn Future<Output = Result<RefreshToken, 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<'life0, 'life1, 'async_trait>( &'life0 mut self, clock: &'life1 dyn Clock, refresh_token: RefreshToken, ) -> Pin<Box<dyn Future<Output = Result<RefreshToken, Self::Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Implementors§