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§
Required Methods§
Sourcefn 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 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
Sourcefn 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 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
Sourcefn 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 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 useclock: The clock used to generate timestampscompat_session: The compat session associated with this refresh tokencompat_access_token: The compat access token created alongside this refresh tokentoken: The token of the refresh token
Sourcefn 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,
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 timestampscompat_refresh_token: The compat refresh token to consume
§Errors
- Returns
Self::Errorif the underlying repository fails - Returns an error if
compat_refresh_tokenis not valid to be consumed. - Returns an error if no refresh tokens would be consumed.