1pub mod access_controller;
15pub mod encryption_engine;
16pub mod input_validator;
17pub mod pii_scrubber;
18pub mod rate_limiter;
19pub mod secrets_manager;
20pub mod threat_detector;
21
22pub use access_controller::{AccessController, Permission, Role};
23pub use encryption_engine::{
24 derive_key_from_password, generate_salt, EncryptedData, EncryptionAlgorithm, EncryptionConfig,
25 EncryptionEngine, EncryptionError, EncryptionKey,
26};
27pub use input_validator::{InputValidator, ValidationResult};
28pub use pii_scrubber::{PiiScrubber, ScrubResult};
29pub use rate_limiter::{RateLimitConfig, RateLimiter};
30pub use secrets_manager::{
31 AuditAction, AuditLogEntry, SecretMetadataInfo, SecretsManager, SecretsManagerConfig,
32};
33pub use threat_detector::{
34 DetectionRule, ResponseAction, ResponseRule, Threat, ThreatDetector, ThreatDetectorConfig,
35 ThreatError, ThreatLevel, ThreatStats, ThreatType,
36};
37
38pub struct SecurityGateway {
40 input_validator: InputValidator,
41 pii_scrubber: PiiScrubber,
42 access_controller: AccessController,
43 rate_limiter: RateLimiter,
44}
45
46impl SecurityGateway {
47 pub fn new() -> Self {
48 Self {
49 input_validator: InputValidator::new(),
50 pii_scrubber: PiiScrubber::new(),
51 access_controller: AccessController::new(),
52 rate_limiter: RateLimiter::new(),
53 }
54 }
55
56 pub async fn validate_input(&self, input: &str) -> anyhow::Result<String> {
58 self.input_validator.validate(input)?;
60
61 let result = self.pii_scrubber.scrub(input);
63
64 Ok(result.scrubbed)
65 }
66
67 pub fn check_access(&self, user_id: &str, resource: &str, action: &str) -> bool {
69 self.access_controller.check(user_id, resource, action)
70 }
71
72 pub async fn check_rate(&self, key: &str) -> anyhow::Result<bool> {
74 self.rate_limiter.check(key).await
75 }
76}
77
78impl Default for SecurityGateway {
79 fn default() -> Self {
80 Self::new()
81 }
82}