pub struct CookieManager { /* private fields */ }Expand description
Thread-safe cookie challenge manager
Implementations§
Source§impl CookieManager
impl CookieManager
Sourcepub fn new(config: CookieConfig) -> Result<Self, CookieError>
pub fn new(config: CookieConfig) -> Result<Self, CookieError>
Create a new cookie manager with the given configuration
§Errors
Returns CookieError::InvalidSecretKey if the secret key is all zeros.
Sourcepub fn new_fallback(config: CookieConfig) -> Self
pub fn new_fallback(config: CookieConfig) -> Self
Create a new cookie manager with a best-effort fallback for invalid secrets.
This avoids panicking on invalid keys and logs a warning instead.
Sourcepub fn config(&self) -> &CookieConfig
pub fn config(&self) -> &CookieConfig
Get the configuration
Generate a tracking cookie for an actor
Validate a cookie value for an actor
Sourcepub fn correlate_actor(&self, cookie_value: &str) -> Option<String>
pub fn correlate_actor(&self, cookie_value: &str) -> Option<String>
Correlate cookie to actor - extract actor_id from valid cookie
This uses timing-safe comparison to find the actor whose hash matches. Note: This is O(n) where n is number of tracked actors. For large scale, consider maintaining a reverse lookup table.
Sourcepub fn stats(&self) -> &CookieStats
pub fn stats(&self) -> &CookieStats
Get statistics
Sourcepub fn cleanup_expired(&self) -> usize
pub fn cleanup_expired(&self) -> usize
Remove expired challenges
Trait Implementations§
Source§impl Debug for CookieManager
impl Debug for CookieManager
Source§impl Interrogator for CookieManager
impl Interrogator for CookieManager
Source§fn challenge_level(&self) -> u8
fn challenge_level(&self) -> u8
Challenge level (1-5, lower = softer)
Source§fn generate_challenge(&self, actor_id: &str) -> ChallengeResponse
fn generate_challenge(&self, actor_id: &str) -> ChallengeResponse
Generate a challenge for the actor
Source§fn validate_response(&self, actor_id: &str, response: &str) -> ValidationResult
fn validate_response(&self, actor_id: &str, response: &str) -> ValidationResult
Validate a challenge response
Source§fn should_escalate(&self, _actor_id: &str) -> bool
fn should_escalate(&self, _actor_id: &str) -> bool
Check if actor should escalate to next level
Auto Trait Implementations§
impl !Freeze for CookieManager
impl !RefUnwindSafe for CookieManager
impl Send for CookieManager
impl Sync for CookieManager
impl Unpin for CookieManager
impl UnsafeUnpin for CookieManager
impl UnwindSafe for CookieManager
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
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Convert
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.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Convert
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Convert
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Convert
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§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>
Converts
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>
Converts
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