pub struct MemoryChallengeStore { /* private fields */ }Expand description
In-memory ChallengeStore: mutex-guarded map with lazy expiry
and a capacity cap. Single-process only — state does not survive
restarts (an unconsumed challenge dies with the process, which
fails closed), and replicas sharing verification traffic would
each accept the same challenge once. Deployments spanning
processes or hosts need a ChallengeStore over shared storage
whose consume is atomic (e.g. a single-row DELETE … RETURNING).
Implementations§
Trait Implementations§
Source§impl ChallengeStore for MemoryChallengeStore
impl ChallengeStore for MemoryChallengeStore
Source§fn issue(
&self,
session_context: &[u8],
ttl_seconds: i64,
) -> Result<(Vec<u8>, i64), String>
fn issue( &self, session_context: &[u8], ttl_seconds: i64, ) -> Result<(Vec<u8>, i64), String>
Generate a fresh challenge bound to
session_context (which must
be empty or exactly 32 bytes; empty = unbound), valid for
ttl_seconds (which must be positive). Returns the challenge and
its expiry (unix seconds).Source§fn validate(
&self,
challenge: &[u8],
session_context: &[u8],
now: i64,
) -> Result<(), String>
fn validate( &self, challenge: &[u8], session_context: &[u8], now: i64, ) -> Result<(), String>
Report whether
challenge could be consumed right now — issued,
unexpired, unconsumed, and bound to session_context — WITHOUT
consuming it. verify_bundle calls this before any signature work.Source§fn consume(
&self,
challenge: &[u8],
session_context: &[u8],
now: i64,
) -> Result<(), String>
fn consume( &self, challenge: &[u8], session_context: &[u8], now: i64, ) -> Result<(), String>
Atomically remove the challenge’s issuance record. Exactly one
consume of a given challenge may ever succeed; all later calls
(and calls with a mismatched
session_context, which do NOT
remove the record) return an error. Removing the record keeps the
store’s capacity a count of PENDING challenges — a consumed
challenge frees its slot immediately.Auto Trait Implementations§
impl !Freeze for MemoryChallengeStore
impl Forget for MemoryChallengeStore
impl RefUnwindSafe for MemoryChallengeStore
impl Send for MemoryChallengeStore
impl Sync for MemoryChallengeStore
impl Unpin for MemoryChallengeStore
impl UnsafeUnpin for MemoryChallengeStore
impl UnwindSafe for MemoryChallengeStore
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