pub struct BrowserSessions {
lifetime: Duration,
clock: Clock,
inner: Mutex<Inner>,
}Expand description
Every browser session and ticket this server holds.
Each map holds at most one entry per account, or one per sign-in inside its grace, so the store is bounded by the number of accounts. Every call first removes what has run out: expired tickets, accounts past their deadline, sessions left holding none, and replaced ids past their grace.
Fields§
§lifetime: Duration§clock: Clock§inner: Mutex<Inner>Implementations§
Source§impl BrowserSessions
impl BrowserSessions
Sourcepub fn new(lifetime: Duration) -> Self
pub fn new(lifetime: Duration) -> Self
An empty store whose sign-ins last lifetime, counted from each
sign-in. Use does not extend it.
Sourcepub fn with_clock(lifetime: Duration, clock: Clock) -> Self
pub fn with_clock(lifetime: Duration, clock: Clock) -> Self
The same, reading the time from clock, for a test that ages the
store without waiting.
fn inner(&self, now: OffsetDateTime) -> MutexGuard<'_, Inner>
Sourcepub fn mint(&self, account: &str) -> Minted
pub fn mint(&self, account: &str) -> Minted
Mints a ticket for account, replacing any it already had.
The caller checks the e-stop and the account’s own agent token.
Sourcepub fn redeem(&self, ticket: &str, cookie: Option<&str>) -> Option<SignedIn>
pub fn redeem(&self, ticket: &str, cookie: Option<&str>) -> Option<SignedIn>
Spends ticket and signs its account in to the browser that
presented cookie, or to a new session when it presented none that
is live.
The account’s deadline is now plus the lifetime. It leaves any other
session, and the session it joins gets a new id. None when the
ticket is unknown, used or expired, and then nothing changes.
The caller checks the host, Sec-Fetch-Site and the e-stop first, so
a refused request leaves the ticket as it was.
Sourcepub fn browser(&self, cookie: &str) -> Option<Browser>
pub fn browser(&self, cookie: &str) -> Option<Browser>
The session cookie names: its current id, or an id it replaced
inside that id’s grace.
Sourcepub fn revoke_account(&self, account: &str)
pub fn revoke_account(&self, account: &str)
Takes account out of its browser and drops its ticket, as an
account’s deletion or erasure does.
Sourcepub fn revoke_all(&self)
pub fn revoke_all(&self)
Ends every session, replaced id and ticket, as the e-stop’s Revoke does. Nothing brings them back.
Trait Implementations§
Source§impl Debug for BrowserSessions
impl Debug for BrowserSessions
Auto Trait Implementations§
impl !Freeze for BrowserSessions
impl !RefUnwindSafe for BrowserSessions
impl Send for BrowserSessions
impl Sync for BrowserSessions
impl Unpin for BrowserSessions
impl UnsafeUnpin for BrowserSessions
impl !UnwindSafe for BrowserSessions
Blanket Implementations§
§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more