Skip to main content

oxigdal_security/
lib.rs

1//! Enterprise security features for OxiGDAL.
2//!
3//! This crate provides comprehensive security features including:
4//! - End-to-end encryption (at rest and in transit)
5//! - Access control (RBAC and ABAC)
6//! - Data lineage tracking
7//! - Audit logging
8//! - Multi-tenancy support
9//! - Data anonymization
10//! - Compliance reporting (GDPR, HIPAA, FedRAMP)
11//! - Security scanning
12
13#![deny(clippy::unwrap_used)]
14#![deny(clippy::panic)]
15#![warn(missing_docs)]
16
17pub mod access_control;
18pub mod anonymization;
19pub mod audit;
20pub mod compliance;
21pub mod encryption;
22pub mod error;
23pub mod lineage;
24pub mod multitenancy;
25pub mod scanning;
26
27pub use error::{Result, SecurityError};
28
29/// Security configuration.
30#[derive(Debug, Clone)]
31pub struct SecurityConfig {
32    /// Enable encryption.
33    pub encryption_enabled: bool,
34    /// Enable access control.
35    pub access_control_enabled: bool,
36    /// Enable audit logging.
37    pub audit_logging_enabled: bool,
38    /// Enable lineage tracking.
39    pub lineage_tracking_enabled: bool,
40    /// Enable multi-tenancy.
41    pub multitenancy_enabled: bool,
42}
43
44impl Default for SecurityConfig {
45    fn default() -> Self {
46        Self {
47            encryption_enabled: true,
48            access_control_enabled: true,
49            audit_logging_enabled: true,
50            lineage_tracking_enabled: true,
51            multitenancy_enabled: false,
52        }
53    }
54}
55
56impl SecurityConfig {
57    /// Create a new security configuration.
58    pub fn new() -> Self {
59        Self::default()
60    }
61
62    /// Enable encryption.
63    pub fn with_encryption(mut self, enabled: bool) -> Self {
64        self.encryption_enabled = enabled;
65        self
66    }
67
68    /// Enable access control.
69    pub fn with_access_control(mut self, enabled: bool) -> Self {
70        self.access_control_enabled = enabled;
71        self
72    }
73
74    /// Enable audit logging.
75    pub fn with_audit_logging(mut self, enabled: bool) -> Self {
76        self.audit_logging_enabled = enabled;
77        self
78    }
79
80    /// Enable lineage tracking.
81    pub fn with_lineage_tracking(mut self, enabled: bool) -> Self {
82        self.lineage_tracking_enabled = enabled;
83        self
84    }
85
86    /// Enable multi-tenancy.
87    pub fn with_multitenancy(mut self, enabled: bool) -> Self {
88        self.multitenancy_enabled = enabled;
89        self
90    }
91
92    /// Create a secure configuration with all features enabled.
93    pub fn secure() -> Self {
94        Self {
95            encryption_enabled: true,
96            access_control_enabled: true,
97            audit_logging_enabled: true,
98            lineage_tracking_enabled: true,
99            multitenancy_enabled: true,
100        }
101    }
102
103    /// Create a minimal configuration.
104    pub fn minimal() -> Self {
105        Self {
106            encryption_enabled: true,
107            access_control_enabled: false,
108            audit_logging_enabled: false,
109            lineage_tracking_enabled: false,
110            multitenancy_enabled: false,
111        }
112    }
113}
114
115#[cfg(test)]
116mod tests {
117    use super::*;
118
119    #[test]
120    fn test_security_config() {
121        let config = SecurityConfig::new()
122            .with_encryption(true)
123            .with_access_control(true);
124
125        assert!(config.encryption_enabled);
126        assert!(config.access_control_enabled);
127    }
128
129    #[test]
130    fn test_secure_config() {
131        let config = SecurityConfig::secure();
132        assert!(config.encryption_enabled);
133        assert!(config.access_control_enabled);
134        assert!(config.audit_logging_enabled);
135        assert!(config.lineage_tracking_enabled);
136        assert!(config.multitenancy_enabled);
137    }
138
139    #[test]
140    fn test_minimal_config() {
141        let config = SecurityConfig::minimal();
142        assert!(config.encryption_enabled);
143        assert!(!config.access_control_enabled);
144        assert!(!config.audit_logging_enabled);
145    }
146}