1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
//! Authentication module
//!
//! ## Overview
//!
//! API key-based authentication with:
//! - Cryptographically secure key generation
//! - Argon2id password hashing
//! - Multiple storage backends (Memory, File, Redis)
//! - Role-based access control via tiers
//!
//! ## Architecture
//!
//! ```text
//! Request → AuthMiddleware → [Extract Key] → [Validate] → Handler
//! ↓ ↓
//! AuthService KeyStorage
//! ```
//!
//! ## Usage
//!
//! ```rust,ignore
//! use llm_shield_api::auth::{AuthService, MemoryKeyStorage};
//! use std::sync::Arc;
//!
//! // Create service
//! let storage = Arc::new(MemoryKeyStorage::new());
//! let auth_service = AuthService::new(storage);
//!
//! // Create a key
//! let response = auth_service.create_key(
//! "My App".to_string(),
//! RateLimitTier::Pro,
//! Some(365)
//! ).await?;
//!
//! println!("API Key: {}", response.key); // Only shown once!
//!
//! // Validate a key
//! let key = auth_service.validate_key(&api_key).await?;
//! ```
// Re-exports
pub use AuthService;
pub use ;
pub use ;