Skip to main content

authx_core/models/
api_key.rs

1use chrono::{DateTime, Utc};
2use serde::{Deserialize, Serialize};
3use uuid::Uuid;
4
5#[derive(Debug, Clone, Serialize, Deserialize)]
6pub struct ApiKey {
7    pub id: Uuid,
8    pub user_id: Uuid,
9    pub org_id: Option<Uuid>,
10    pub key_hash: String,
11    pub prefix: String,
12    pub name: String,
13    pub scopes: Vec<String>,
14    pub expires_at: Option<DateTime<Utc>>,
15    pub last_used_at: Option<DateTime<Utc>>,
16}
17
18#[derive(Debug, Clone)]
19pub struct CreateApiKey {
20    pub user_id: Uuid,
21    pub org_id: Option<Uuid>,
22    pub key_hash: String,
23    pub prefix: String,
24    pub name: String,
25    pub scopes: Vec<String>,
26    pub expires_at: Option<DateTime<Utc>>,
27}