Skip to main content

RefreshRotator

Struct RefreshRotator 

Source
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>

Source

pub fn new(store: &'s S, ttl_seconds: i64) -> Self

Source

pub fn ttl_seconds(&self) -> i64

Source

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.

Source

pub async fn rotate( &self, presented: &str, now: i64, ) -> Result<Rotated, RefreshError>

Rotate presented → fresh successor.

Failure modes (in priority order):

Source

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>
where S: ?Sized,

§

impl<'s, S> RefUnwindSafe for RefreshRotator<'s, S>
where S: RefUnwindSafe + ?Sized,

§

impl<'s, S> Send for RefreshRotator<'s, S>
where S: ?Sized,

§

impl<'s, S> Sync for RefreshRotator<'s, S>
where S: ?Sized,

§

impl<'s, S> Unpin for RefreshRotator<'s, S>
where S: ?Sized,

§

impl<'s, S> UnsafeUnpin for RefreshRotator<'s, S>
where S: ?Sized,

§

impl<'s, S> UnwindSafe for RefreshRotator<'s, S>
where S: RefUnwindSafe + ?Sized,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.