pub struct CredentialCache { /* private fields */ }Expand description
TTL-based credential cache for avoiding repeated LDAP binds.
Stores hashed credentials with expiry timestamps based on tick counts (no floating point).
Implementations§
Source§impl CredentialCache
impl CredentialCache
Sourcepub fn new(ttl_ticks: u64, max_entries: usize) -> Self
pub fn new(ttl_ticks: u64, max_entries: usize) -> Self
Create a new credential cache.
ttl_ticks is the number of timer ticks before an entry expires.
max_entries limits the cache size.
Sourcepub fn lookup(
&self,
username: &str,
password_hash: &[u8; 32],
current_tick: u64,
) -> Option<&str>
pub fn lookup( &self, username: &str, password_hash: &[u8; 32], current_tick: u64, ) -> Option<&str>
Check if a cached credential exists and is still valid.
Returns the bind DN if the password hash matches.
Sourcepub fn store(
&mut self,
username: &str,
password_hash: [u8; 32],
bind_dn: &str,
current_tick: u64,
)
pub fn store( &mut self, username: &str, password_hash: [u8; 32], bind_dn: &str, current_tick: u64, )
Store a credential in the cache.
Sourcepub fn purge_expired(&mut self, current_tick: u64)
pub fn purge_expired(&mut self, current_tick: u64)
Remove expired entries.