pub struct PermissionValidator {
Roles: Arc<RwLock<HashMap<String, Role>>>,
Permissions: Arc<RwLock<HashMap<String, Permission>>>,
OperationPermissions: HashMap<String, Vec<String>>,
ValidationTimeoutMillis: u64,
}Expand description
Permission validator for IPC operations
Fields§
§Roles: Arc<RwLock<HashMap<String, Role>>>Role definitions indexed by role name
Permissions: Arc<RwLock<HashMap<String, Permission>>>Permission definitions indexed by permission name
OperationPermissions: HashMap<String, Vec<String>>Operation to permission mapping
ValidationTimeoutMillis: u64Maximum time allowed for permission validation (milliseconds)
Implementations§
Source§impl PermissionValidator
impl PermissionValidator
Sourcefn BuildOperationMapping() -> HashMap<String, Vec<String>>
fn BuildOperationMapping() -> HashMap<String, Vec<String>>
Build operation to permission mapping
§Returns
HashMap mapping operation names to required permission strings
Sourcepub fn CreateSecurityContext(
UserId: String,
Roles: Vec<String>,
IpAddress: String,
DirectPermissions: Vec<String>,
) -> SecurityContext
pub fn CreateSecurityContext( UserId: String, Roles: Vec<String>, IpAddress: String, DirectPermissions: Vec<String>, ) -> SecurityContext
Sourcepub async fn ValidatePermission(
&self,
Operation: &str,
Context: &SecurityContext,
) -> Result<(), String>
pub async fn ValidatePermission( &self, Operation: &str, Context: &SecurityContext, ) -> Result<(), String>
Validate permission for an operation with security context
§Parameters
Operation: The operation being performedContext: Security context containing user info and roles
§Returns
Ok(()) if permission granted, Err with message if denied
§Security Notes
- All operations require explicit permission grant (default deny)
- Validation is performed server-side only
- IP address can be used for additional restrictions
- Timestamp can be used for time-based restrictions
Sourceasync fn ValidatePermissionInternal(
&self,
Operation: &str,
Context: &SecurityContext,
) -> Result<(), String>
async fn ValidatePermissionInternal( &self, Operation: &str, Context: &SecurityContext, ) -> Result<(), String>
Sourceasync fn AggregateUserPermissions(
&self,
Context: &SecurityContext,
) -> Result<Vec<String>, String>
async fn AggregateUserPermissions( &self, Context: &SecurityContext, ) -> Result<Vec<String>, String>
Sourcepub async fn RegisterPermission(
&self,
Permission: Permission,
) -> Result<(), String>
pub async fn RegisterPermission( &self, Permission: Permission, ) -> Result<(), String>
Register a permission definition
§Parameters
Permission: Permission definition to register
/// Returns Result indicating success or error
Sourcepub async fn GetRolePermissions(&self, RoleName: &str) -> Vec<String>
pub async fn GetRolePermissions(&self, RoleName: &str) -> Vec<String>
Sourcepub async fn HasPermission(
&self,
Context: &SecurityContext,
PermissionName: &str,
) -> bool
pub async fn HasPermission( &self, Context: &SecurityContext, PermissionName: &str, ) -> bool
Check if a user has a specific permission
§Parameters
Context: Security context for the userPermissionName: Permission name to check
/// Returns true if user has permission, false otherwise
Sourcepub async fn InitializeDefaults(&self) -> Result<(), String>
pub async fn InitializeDefaults(&self) -> Result<(), String>
Auto Trait Implementations§
impl Freeze for PermissionValidator
impl !RefUnwindSafe for PermissionValidator
impl Send for PermissionValidator
impl Sync for PermissionValidator
impl Unpin for PermissionValidator
impl !UnwindSafe for PermissionValidator
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
Mutably borrows from an owned value. Read more
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Convert
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Convert
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Convert
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Convert
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.§impl<T> DowncastSync for T
impl<T> DowncastSync for T
§impl<T> FutureExt for T
impl<T> FutureExt for T
§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
Wrap the input message
T in a tonic::Request§impl<L> LayerExt<L> for L
impl<L> LayerExt<L> for L
§fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
Applies the layer to a service and wraps it in [
Layered].