pub struct SecurityContext { /* private fields */ }Expand description
Security context entity for managing access control and security policies.
The SecurityContext encapsulates all security-related information needed
for pipeline processing operations. It enforces access control policies,
maintains audit information, and integrates with encryption key management.
§Security Features
- Permission Management: Fine-grained access control
- Security Classification: Hierarchical data sensitivity levels
- Session Tracking: Unique session identification for audit trails
- Key Integration: Encryption key management and association
- Audit Support: Comprehensive logging and tracking capabilities
- Policy Validation: Enforcement of security requirements and constraints
§Usage Examples
§Creating a Basic Security Context
§Creating Context with Specific Permissions
§Managing Permissions Dynamically
§Security Level Validation
§Encryption Key Management
§Creating Restricted Contexts
§Audit and Session Management
Implementations§
Source§impl SecurityContext
impl SecurityContext
Sourcepub fn new(user_id: Option<String>, security_level: SecurityLevel) -> Self
pub fn new(user_id: Option<String>, security_level: SecurityLevel) -> Self
Creates a new security context
Sourcepub fn with_permissions(
user_id: Option<String>,
permissions: Vec<Permission>,
security_level: SecurityLevel,
) -> Self
pub fn with_permissions( user_id: Option<String>, permissions: Vec<Permission>, security_level: SecurityLevel, ) -> Self
Creates a security context with permissions
Sourcepub fn session_id(&self) -> Uuid
pub fn session_id(&self) -> Uuid
Gets the session ID
Sourcepub fn permissions(&self) -> &[Permission]
pub fn permissions(&self) -> &[Permission]
Gets the permissions
Sourcepub fn encryption_key_id(&self) -> Option<&str>
pub fn encryption_key_id(&self) -> Option<&str>
Gets the encryption key ID
Sourcepub fn integrity_required(&self) -> bool
pub fn integrity_required(&self) -> bool
Checks if integrity is required
Sourcepub fn audit_enabled(&self) -> bool
pub fn audit_enabled(&self) -> bool
Checks if audit is enabled
Sourcepub fn security_level(&self) -> &SecurityLevel
pub fn security_level(&self) -> &SecurityLevel
Gets the security level
Sourcepub fn created_at(&self) -> DateTime<Utc>
pub fn created_at(&self) -> DateTime<Utc>
Gets the creation timestamp
Sourcepub fn set_user_id(&mut self, user_id: Option<String>)
pub fn set_user_id(&mut self, user_id: Option<String>)
Sets the user ID
Sourcepub fn add_permission(&mut self, permission: Permission)
pub fn add_permission(&mut self, permission: Permission)
Adds a permission
Sourcepub fn remove_permission(&mut self, permission: &Permission)
pub fn remove_permission(&mut self, permission: &Permission)
Removes a permission
Sourcepub fn set_encryption_key_id(&mut self, key_id: Option<String>)
pub fn set_encryption_key_id(&mut self, key_id: Option<String>)
Sets the encryption key ID
Sourcepub fn set_integrity_required(&mut self, required: bool)
pub fn set_integrity_required(&mut self, required: bool)
Sets integrity requirement
Sourcepub fn set_audit_enabled(&mut self, enabled: bool)
pub fn set_audit_enabled(&mut self, enabled: bool)
Sets audit enablement
Sourcepub fn set_security_level(&mut self, level: SecurityLevel)
pub fn set_security_level(&mut self, level: SecurityLevel)
Sets the security level
Sourcepub fn add_metadata(&mut self, key: String, value: String)
pub fn add_metadata(&mut self, key: String, value: String)
Adds metadata
Sourcepub fn remove_metadata(&mut self, key: &str)
pub fn remove_metadata(&mut self, key: &str)
Removes metadata
Sourcepub fn has_permission(&self, permission: &Permission) -> bool
pub fn has_permission(&self, permission: &Permission) -> bool
Checks if the context has a specific permission
Sourcepub fn can_encrypt(&self) -> bool
pub fn can_encrypt(&self) -> bool
Checks if the context can perform encryption
Sourcepub fn can_decrypt(&self) -> bool
pub fn can_decrypt(&self) -> bool
Checks if the context can perform decryption
Sourcepub fn can_compress(&self) -> bool
pub fn can_compress(&self) -> bool
Checks if the context can perform compression
Sourcepub fn can_decompress(&self) -> bool
pub fn can_decompress(&self) -> bool
Checks if the context can perform decompression
Sourcepub fn can_execute(&self) -> bool
pub fn can_execute(&self) -> bool
Checks if the context can execute
Sourcepub fn meets_security_level(&self, minimum_level: &SecurityLevel) -> bool
pub fn meets_security_level(&self, minimum_level: &SecurityLevel) -> bool
Checks if the security level meets the minimum requirement
Sourcepub fn restrict(&self, allowed_permissions: Vec<Permission>) -> Self
pub fn restrict(&self, allowed_permissions: Vec<Permission>) -> Self
Creates a restricted copy of the security context
Sourcepub fn validate(&self) -> Result<(), PipelineError>
pub fn validate(&self) -> Result<(), PipelineError>
Validates the security context
Trait Implementations§
Source§impl Clone for SecurityContext
impl Clone for SecurityContext
Source§fn clone(&self) -> SecurityContext
fn clone(&self) -> SecurityContext
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for SecurityContext
impl Debug for SecurityContext
Source§impl Default for SecurityContext
impl Default for SecurityContext
Source§impl<'de> Deserialize<'de> for SecurityContext
impl<'de> Deserialize<'de> for SecurityContext
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Auto Trait Implementations§
impl Freeze for SecurityContext
impl RefUnwindSafe for SecurityContext
impl Send for SecurityContext
impl Sync for SecurityContext
impl Unpin for SecurityContext
impl UnwindSafe for SecurityContext
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more