pulseengine_mcp_auth/
models.rs

1//! Authentication models
2
3use chrono::{DateTime, Utc};
4use serde::{Deserialize, Serialize};
5
6/// API key for authentication
7#[derive(Debug, Clone, Serialize, Deserialize)]
8pub struct ApiKey {
9    pub id: String,
10    pub name: String,
11    pub key: String,
12    pub role: Role,
13    pub created_at: DateTime<Utc>,
14    pub last_used: Option<DateTime<Utc>>,
15    pub expires_at: Option<DateTime<Utc>>,
16}
17
18/// User role
19#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
20pub enum Role {
21    Admin,
22    Operator,
23    Viewer,
24}
25
26/// Authentication result
27#[derive(Debug)]
28pub struct AuthResult {
29    pub success: bool,
30    pub user_id: Option<String>,
31    pub roles: Vec<Role>,
32    pub message: Option<String>,
33}
34
35/// Authentication context
36#[derive(Debug, Clone)]
37pub struct AuthContext {
38    pub user_id: Option<String>,
39    pub roles: Vec<Role>,
40    pub api_key_id: Option<String>,
41}