pub struct SecureApiKey {
pub id: String,
pub name: String,
pub secret_hash: Option<String>,
pub salt: Option<Salt>,
pub role: Role,
pub created_at: DateTime<Utc>,
pub expires_at: Option<DateTime<Utc>>,
pub last_used: Option<DateTime<Utc>>,
pub ip_whitelist: Vec<String>,
pub active: bool,
pub usage_count: u64,
}
Expand description
Secure API key for storage (without plain text key)
Fields§
§id: String
Unique key identifier (format: lmcp_{role}{timestamp}{random})
name: String
Human-readable name/description
secret_hash: Option<String>
Secure hash of the secret token (for storage)
salt: Option<Salt>
Salt used for hashing the secret token
role: Role
Role-based permissions
created_at: DateTime<Utc>
Creation timestamp
expires_at: Option<DateTime<Utc>>
Optional expiration timestamp
last_used: Option<DateTime<Utc>>
Last time this key was used
ip_whitelist: Vec<String>
IP address whitelist (empty = all IPs allowed)
active: bool
Is the key currently active
usage_count: u64
Usage count
Implementations§
Source§impl SecureApiKey
impl SecureApiKey
Sourcepub fn to_api_key(&self) -> ApiKey
pub fn to_api_key(&self) -> ApiKey
Convert back to ApiKey (without plain text key)
Sourcepub fn is_expired(&self) -> bool
pub fn is_expired(&self) -> bool
Check if the key is expired
Sourcepub fn verify_key(&self, provided_key: &str) -> Result<bool, HashingError>
pub fn verify_key(&self, provided_key: &str) -> Result<bool, HashingError>
Verify if the provided key matches the stored hash
Trait Implementations§
Source§impl Clone for SecureApiKey
impl Clone for SecureApiKey
Source§fn clone(&self) -> SecureApiKey
fn clone(&self) -> SecureApiKey
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreSource§impl Debug for SecureApiKey
impl Debug for SecureApiKey
Source§impl<'de> Deserialize<'de> for SecureApiKey
impl<'de> Deserialize<'de> for SecureApiKey
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for SecureApiKey
impl RefUnwindSafe for SecureApiKey
impl Send for SecureApiKey
impl Sync for SecureApiKey
impl Unpin for SecureApiKey
impl UnwindSafe for SecureApiKey
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