pub struct ApiKeyModel {
pub id: u64,
pub key_id: String,
pub key_hash: String,
pub service_id: u64,
pub sub_service_id: u64,
pub created_at: u64,
pub last_used: u64,
pub expires_at: u64,
pub is_enabled: bool,
pub default_headers: Vec<u8>,
pub description: String,
}Expand description
Long-lived API Key model stored in database
Fields§
§id: u64Unique database ID
key_id: StringAPI key identifier (e.g., “ak_2n4f8…”)
key_hash: StringHashed secret part of the API key
service_id: u64Service ID this key belongs to
sub_service_id: u64Sub-service ID (zero means no sub-service)
created_at: u64When this key was created (seconds since epoch)
last_used: u64When this key was last used (seconds since epoch)
expires_at: u64When this key expires (seconds since epoch)
is_enabled: boolWhether this key is enabled
default_headers: Vec<u8>Default headers to include in access tokens (JSON-encoded)
description: StringHuman-readable description
Implementations§
Source§impl ApiKeyModel
impl ApiKeyModel
Sourcepub fn find_by_key_id(key_id: &str, db: &RocksDb) -> Result<Option<Self>, Error>
pub fn find_by_key_id(key_id: &str, db: &RocksDb) -> Result<Option<Self>, Error>
Find API key by key_id
Sourcepub fn find_by_id(id: u64, db: &RocksDb) -> Result<Option<Self>, Error>
pub fn find_by_id(id: u64, db: &RocksDb) -> Result<Option<Self>, Error>
Find API key by database ID
Sourcepub fn validates_key(&self, full_key: &str) -> bool
pub fn validates_key(&self, full_key: &str) -> bool
Validate if the given full key matches this stored key
Sourcepub fn is_expired(&self) -> bool
pub fn is_expired(&self) -> bool
Check if key is expired
Sourcepub fn update_last_used(&mut self, db: &RocksDb) -> Result<(), Error>
pub fn update_last_used(&mut self, db: &RocksDb) -> Result<(), Error>
Update last used timestamp
Sourcepub fn get_default_headers(&self) -> BTreeMap<String, String>
pub fn get_default_headers(&self) -> BTreeMap<String, String>
Get default headers as BTreeMap
Sourcepub fn set_default_headers(&mut self, headers: &BTreeMap<String, String>)
pub fn set_default_headers(&mut self, headers: &BTreeMap<String, String>)
Set default headers from BTreeMap
Sourcepub fn service_id(&self) -> ServiceId
pub fn service_id(&self) -> ServiceId
Get service ID
Trait Implementations§
Source§impl Clone for ApiKeyModel
impl Clone for ApiKeyModel
Source§fn clone(&self) -> ApiKeyModel
fn clone(&self) -> ApiKeyModel
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 ApiKeyModel
impl Debug for ApiKeyModel
Source§impl Default for ApiKeyModel
impl Default for ApiKeyModel
Source§impl From<&GeneratedApiKey> for ApiKeyModel
impl From<&GeneratedApiKey> for ApiKeyModel
Source§fn from(key: &GeneratedApiKey) -> Self
fn from(key: &GeneratedApiKey) -> Self
Converts to this type from the input type.
Source§impl Message for ApiKeyModel
impl Message for ApiKeyModel
Source§fn encoded_len(&self) -> usize
fn encoded_len(&self) -> usize
Returns the encoded length of the message without a length delimiter.
Source§fn encode(&self, buf: &mut impl BufMut) -> Result<(), EncodeError>where
Self: Sized,
fn encode(&self, buf: &mut impl BufMut) -> Result<(), EncodeError>where
Self: Sized,
Encodes the message to a buffer. Read more
Source§fn encode_to_vec(&self) -> Vec<u8> ⓘwhere
Self: Sized,
fn encode_to_vec(&self) -> Vec<u8> ⓘwhere
Self: Sized,
Encodes the message to a newly allocated buffer.
Source§fn encode_length_delimited(
&self,
buf: &mut impl BufMut,
) -> Result<(), EncodeError>where
Self: Sized,
fn encode_length_delimited(
&self,
buf: &mut impl BufMut,
) -> Result<(), EncodeError>where
Self: Sized,
Encodes the message with a length-delimiter to a buffer. Read more
Source§fn encode_length_delimited_to_vec(&self) -> Vec<u8> ⓘwhere
Self: Sized,
fn encode_length_delimited_to_vec(&self) -> Vec<u8> ⓘwhere
Self: Sized,
Encodes the message with a length-delimiter to a newly allocated buffer.
Source§fn decode(buf: impl Buf) -> Result<Self, DecodeError>where
Self: Default,
fn decode(buf: impl Buf) -> Result<Self, DecodeError>where
Self: Default,
Decodes an instance of the message from a buffer. Read more
Source§fn decode_length_delimited(buf: impl Buf) -> Result<Self, DecodeError>where
Self: Default,
fn decode_length_delimited(buf: impl Buf) -> Result<Self, DecodeError>where
Self: Default,
Decodes a length-delimited instance of the message from the buffer.
Source§fn merge(&mut self, buf: impl Buf) -> Result<(), DecodeError>where
Self: Sized,
fn merge(&mut self, buf: impl Buf) -> Result<(), DecodeError>where
Self: Sized,
Decodes an instance of the message from a buffer, and merges it into
self. Read moreSource§fn merge_length_delimited(&mut self, buf: impl Buf) -> Result<(), DecodeError>where
Self: Sized,
fn merge_length_delimited(&mut self, buf: impl Buf) -> Result<(), DecodeError>where
Self: Sized,
Decodes a length-delimited instance of the message from buffer, and
merges it into
self.Auto Trait Implementations§
impl Freeze for ApiKeyModel
impl RefUnwindSafe for ApiKeyModel
impl Send for ApiKeyModel
impl Sync for ApiKeyModel
impl Unpin for ApiKeyModel
impl UnwindSafe for ApiKeyModel
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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