Skip to main content

MemoryTokenStore

Struct MemoryTokenStore 

Source
pub struct MemoryTokenStore { /* private fields */ }
Expand description

Tokens held in this process’s memory.

Wrong for production for the usual reason and one extra: a restart would empty the store, and an empty store answers “unknown token” to everything — which fails safe — but it also loses every revocation, and a revocation that a restart undoes is not a revocation.

Implementations§

Source§

impl MemoryTokenStore

Source

pub fn new() -> MemoryTokenStore

Source

pub fn live_access(&self, now: u64) -> usize

How many access tokens are usable right now. For tests.

Source

pub fn live_refresh(&self, now: u64) -> usize

How many refresh tokens are usable right now. For tests.

Trait Implementations§

Source§

impl Default for MemoryTokenStore

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl TokenStore for MemoryTokenStore

Source§

fn store_access<'a>(&'a self, token: AccessToken) -> StoreFuture<'a, ()>

Source§

fn store_refresh<'a>(&'a self, token: RefreshToken) -> StoreFuture<'a, ()>

Source§

fn find_access<'a>( &'a self, hash: &'a str, ) -> StoreFuture<'a, Option<AccessToken>>

Look a token up by its digest — the record whatever its state, so the caller can tell “revoked” apart from “never existed” and act on it.
Source§

fn find_refresh<'a>( &'a self, hash: &'a str, ) -> StoreFuture<'a, Option<RefreshToken>>

Source§

fn rotate<'a>(&'a self, id: &'a str) -> StoreFuture<'a, bool>

Mark a refresh token rotated, returning whether this call did it. Read more
Source§

fn revoke_access<'a>(&'a self, id: &'a str) -> StoreFuture<'a, ()>

Source§

fn revoke_refresh<'a>(&'a self, id: &'a str) -> StoreFuture<'a, ()>

Source§

fn revoke_family<'a>(&'a self, family: &'a str) -> StoreFuture<'a, usize>

Revoke everything descended from one authorisation, returning how many records changed. This is what a detected replay or reuse calls.
Source§

fn purge<'a>(&'a self, now: u64) -> StoreFuture<'a, usize>

Drop records that are past their lifetime. Housekeeping.

Auto Trait Implementations§

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 = !

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

fn try_from(value: U) -> Result<T, !>

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.