pub(crate) struct SessionStore {
inner: Mutex<Inner>,
revoked: Sender<u64>,
}Fields§
§inner: Mutex<Inner>§revoked: Sender<u64>Counts the logouts, so a socket upgraded with a session hears that it ended.
Implementations§
Source§impl SessionStore
impl SessionStore
fn lock(&self) -> MutexGuard<'_, Inner>
Sourcepub(crate) fn keep_in(
&self,
path: PathBuf,
binding: KeyBinding,
now: Instant,
wall_secs: u64,
)
pub(crate) fn keep_in( &self, path: PathBuf, binding: KeyBinding, now: Instant, wall_secs: u64, )
Keep the live sessions in path from now on, after taking back the ones a restart finds there that are inside their
limits. A file that cannot be trusted is cleared and logged once, with no value from it; the store then starts empty.
Sourcepub(crate) fn mint_code(&self, now: Instant) -> String
pub(crate) fn mint_code(&self, now: Instant) -> String
A new one-time code: 256 random bits, single use, CODE_LIFE.
Sourcepub(crate) fn enter(&self, code: &str, now: Instant) -> Option<Entered>
pub(crate) fn enter(&self, code: &str, now: Instant) -> Option<Entered>
Enter a code: it is spent whether or not it was valid, and a valid one makes a pending
session, which holds no access. None for a wrong, used or expired code.
Sourcepub(crate) fn code_state(&self, code: &str, now: Instant) -> CodeState
pub(crate) fn code_state(&self, code: &str, now: Instant) -> CodeState
Where the code open minted stands. It looks nothing up by anything else.
Sourcepub(crate) fn note_confirm(
&self,
code: &str,
how: ConfirmHow,
now: Instant,
) -> bool
pub(crate) fn note_confirm( &self, code: &str, how: ConfirmHow, now: Instant, ) -> bool
Record how the confirm of the session made from code arrived. False when no pending session of that code waits.
Sourcepub(crate) fn decide(&self, code: &str, accept: bool, now: Instant) -> bool
pub(crate) fn decide(&self, code: &str, accept: bool, now: Instant) -> bool
The person’s answer for the session made from code. True when a pending session of that
code was waiting. Confirming makes the live session (its hashes), and keeps the cookie and
token for the waiting page to collect once.
Sourcepub(crate) fn collect(&self, handle: &str, now: Instant) -> Collected
pub(crate) fn collect(&self, handle: &str, now: Instant) -> Collected
The waiting page asks, with its handle. A grant is handed over exactly once; a discarded, expired, spent or unknown handle is refused.
Sourcepub(crate) fn admit(
&self,
cookie: Option<&str>,
token: Option<&str>,
class: RouteClass,
now: Instant,
) -> bool
pub(crate) fn admit( &self, cookie: Option<&str>, token: Option<&str>, class: RouteClass, now: Instant, ) -> bool
Does this request name a live session? Both needs the token too. A use slides the idle limit.
Sourcepub(crate) fn revoke_all(&self) -> usize
pub(crate) fn revoke_all(&self) -> usize
End every session and every pending sign-in. How many sessions there were.
Sourcepub(crate) fn revoke(&self, id: SessionId, now: Instant) -> bool
pub(crate) fn revoke(&self, id: SessionId, now: Instant) -> bool
End one session (this browser’s): the others stay. False when it was not live. A socket that was upgraded with it hears that it ended.
Sourcepub(crate) fn is_live(&self, id: SessionId, now: Instant) -> bool
pub(crate) fn is_live(&self, id: SessionId, now: Instant) -> bool
Is this session still live? A socket that asks is in use, so it slides the idle limit.
Sourcepub(crate) async fn ended(&self, id: SessionId)
pub(crate) async fn ended(&self, id: SessionId)
Completes when the session has ended: at a logout, and at the first re-check after it expired. A WebSocket is authenticated once, when it is upgraded, so it waits on this.
pub(crate) fn session_count(&self, now: Instant) -> usize
Sourcepub(crate) fn note_failure(&self, now: Instant) -> usize
pub(crate) fn note_failure(&self, now: Instant) -> usize
Count a refused sign-in; how many in the last minute (at most MAX_FAILURES), this one
included. The list is capped, so a flood of refusals holds no more memory than a trickle.
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for SessionStore
impl !RefUnwindSafe for SessionStore
impl !UnwindSafe for SessionStore
impl Send for SessionStore
impl Sync for SessionStore
impl Unpin for SessionStore
impl UnsafeUnpin for SessionStore
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
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.§impl<T> DowncastSync for T
impl<T> DowncastSync for T
impl<A, B, T> HttpServerConnExec<A, B> for Twhere
B: Body,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> 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