pub struct RefreshRotator<'s, S: RefreshStore + ?Sized> { /* private fields */ }Expand description
Mint and rotate refresh tokens against a RefreshStore.
Holds a borrow of the store; the rotator itself is cheap to construct
per request. ttl_seconds is the lifetime applied to every freshly
minted token (root and successor).
Implementations§
Source§impl<'s, S: RefreshStore + ?Sized> RefreshRotator<'s, S>
impl<'s, S: RefreshStore + ?Sized> RefreshRotator<'s, S>
pub fn new(store: &'s S, ttl_seconds: i64) -> Self
pub fn ttl_seconds(&self) -> i64
Sourcepub async fn mint_root(
&self,
user_id: UserId,
device_id: DeviceId,
now: i64,
) -> Result<Rotated, RefreshError>
pub async fn mint_root( &self, user_id: UserId, device_id: DeviceId, now: i64, ) -> Result<Rotated, RefreshError>
Start a fresh chain. Returns the root token + persisted record.
Sourcepub async fn rotate(
&self,
presented: &str,
now: i64,
) -> Result<Rotated, RefreshError>
pub async fn rotate( &self, presented: &str, now: i64, ) -> Result<Rotated, RefreshError>
Rotate presented → fresh successor.
Failure modes (in priority order):
RefreshError::Unknown— no record matches.RefreshError::ChainRevoked— record exists but the chain is dead.RefreshError::Replay— the token was already consumed; the chain is revoked as a side effect of this call.RefreshError::Expired— within TTL is required.
Sourcepub async fn revoke_chain(&self, chain_id: &str) -> Result<(), RefreshError>
pub async fn revoke_chain(&self, chain_id: &str) -> Result<(), RefreshError>
Revoke every token in chain_id. Idempotent. Use on logout or
device-revoke flows.
Auto Trait Implementations§
impl<'s, S> Freeze for RefreshRotator<'s, S>
impl<'s, S> RefUnwindSafe for RefreshRotator<'s, S>
impl<'s, S> Send for RefreshRotator<'s, S>
impl<'s, S> Sync for RefreshRotator<'s, S>
impl<'s, S> Unpin for RefreshRotator<'s, S>
impl<'s, S> UnsafeUnpin for RefreshRotator<'s, S>
impl<'s, S> UnwindSafe for RefreshRotator<'s, S>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more