SecurityContext

Struct SecurityContext 

Source
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

Source

pub fn new(user_id: Option<String>, security_level: SecurityLevel) -> Self

Creates a new security context

Source

pub fn with_permissions( user_id: Option<String>, permissions: Vec<Permission>, security_level: SecurityLevel, ) -> Self

Creates a security context with permissions

Source

pub fn user_id(&self) -> Option<&str>

Gets the user ID

Source

pub fn session_id(&self) -> Uuid

Gets the session ID

Source

pub fn permissions(&self) -> &[Permission]

Gets the permissions

Source

pub fn encryption_key_id(&self) -> Option<&str>

Gets the encryption key ID

Source

pub fn integrity_required(&self) -> bool

Checks if integrity is required

Source

pub fn audit_enabled(&self) -> bool

Checks if audit is enabled

Source

pub fn security_level(&self) -> &SecurityLevel

Gets the security level

Source

pub fn metadata(&self) -> &HashMap<String, String>

Gets the metadata

Source

pub fn created_at(&self) -> DateTime<Utc>

Gets the creation timestamp

Source

pub fn set_user_id(&mut self, user_id: Option<String>)

Sets the user ID

Source

pub fn add_permission(&mut self, permission: Permission)

Adds a permission

Source

pub fn remove_permission(&mut self, permission: &Permission)

Removes a permission

Source

pub fn set_encryption_key_id(&mut self, key_id: Option<String>)

Sets the encryption key ID

Source

pub fn set_integrity_required(&mut self, required: bool)

Sets integrity requirement

Source

pub fn set_audit_enabled(&mut self, enabled: bool)

Sets audit enablement

Source

pub fn set_security_level(&mut self, level: SecurityLevel)

Sets the security level

Source

pub fn add_metadata(&mut self, key: String, value: String)

Adds metadata

Source

pub fn remove_metadata(&mut self, key: &str)

Removes metadata

Source

pub fn has_permission(&self, permission: &Permission) -> bool

Checks if the context has a specific permission

Source

pub fn can_encrypt(&self) -> bool

Checks if the context can perform encryption

Source

pub fn can_decrypt(&self) -> bool

Checks if the context can perform decryption

Source

pub fn can_compress(&self) -> bool

Checks if the context can perform compression

Source

pub fn can_decompress(&self) -> bool

Checks if the context can perform decompression

Source

pub fn can_read(&self) -> bool

Checks if the context can read

Source

pub fn can_write(&self) -> bool

Checks if the context can write

Source

pub fn can_execute(&self) -> bool

Checks if the context can execute

Source

pub fn meets_security_level(&self, minimum_level: &SecurityLevel) -> bool

Checks if the security level meets the minimum requirement

Source

pub fn restrict(&self, allowed_permissions: Vec<Permission>) -> Self

Creates a restricted copy of the security context

Source

pub fn validate(&self) -> Result<(), PipelineError>

Validates the security context

Trait Implementations§

Source§

impl Clone for SecurityContext

Source§

fn clone(&self) -> SecurityContext

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for SecurityContext

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for SecurityContext

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for SecurityContext

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Serialize for SecurityContext

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,