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
50
51
52
53
54
55
56
57
58
59
//! Security middleware and validation for MCP servers
//!
//! This crate provides comprehensive security features for MCP servers including:
//! - Input validation and sanitization
//! - Rate limiting and request throttling
//! - CORS policy management
//! - Request size limits
//! - SQL injection and XSS protection
//!
//! # Quick Start
//!
//! ```rust,ignore
//! use pulseengine_mcp_security::{SecurityMiddleware, SecurityConfig};
//!
//! #[tokio::main]
//! async fn main() -> Result<(), Box<dyn std::error::Error>> {
//! // Create security configuration
//! let config = SecurityConfig {
//! validate_requests: true,
//! rate_limiting: true,
//! max_requests_per_minute: 60,
//! cors_enabled: true,
//! cors_origins: vec!["https://example.com".to_string()],
//! };
//!
//! // Create security middleware
//! let security = SecurityMiddleware::new(config);
//!
//! // The middleware automatically validates and rate-limits
//! // requests when integrated with your MCP server
//!
//! Ok(())
//! }
//! ```
//!
//! # Features
//!
//! - **Input validation**: Comprehensive request validation with schemas
//! - **Rate limiting**: Per-IP and per-user rate limiting
//! - **CORS management**: Configurable cross-origin policies
//! - **Size limits**: Prevent `DoS` through large requests
//! - **Injection protection**: SQL injection and script injection prevention
//! - **Production hardened**: Battle-tested security measures
pub use SecurityConfig;
pub use SecurityMiddleware;
pub use RequestValidator;
/// Default security configuration