pub struct PermissionPolicy {
pub deny: Vec<PermissionRule>,
pub allow: Vec<PermissionRule>,
pub ask: Vec<PermissionRule>,
pub default_decision: PermissionDecision,
pub enabled: bool,
}Expand description
Permission policy configuration
Evaluation order:
- Deny rules - any match results in denial
- Allow rules - any match results in auto-approval
- Ask rules - any match requires user confirmation
- Default - falls back to default_decision
Fields§
§deny: Vec<PermissionRule>Rules that always deny (checked first)
allow: Vec<PermissionRule>Rules that auto-approve without confirmation
ask: Vec<PermissionRule>Rules that always require confirmation
default_decision: PermissionDecisionDefault decision when no rules match
enabled: boolWhether the permission system is enabled
Implementations§
Source§impl PermissionPolicy
impl PermissionPolicy
Sourcepub fn permissive() -> Self
pub fn permissive() -> Self
Create a permissive policy that allows everything
Sourcepub fn check(&self, tool_name: &str, args: &Value) -> PermissionDecision
pub fn check(&self, tool_name: &str, args: &Value) -> PermissionDecision
Check permission for a tool invocation
Returns the permission decision based on rule evaluation order:
- Deny rules (any match = Deny)
- Allow rules (any match = Allow)
- Ask rules (any match = Ask)
- Default decision
Sourcepub fn is_allowed(&self, tool_name: &str, args: &Value) -> bool
pub fn is_allowed(&self, tool_name: &str, args: &Value) -> bool
Check if a tool invocation is allowed (Allow or not Deny)
Sourcepub fn is_denied(&self, tool_name: &str, args: &Value) -> bool
pub fn is_denied(&self, tool_name: &str, args: &Value) -> bool
Check if a tool invocation is denied
Sourcepub fn requires_confirmation(&self, tool_name: &str, args: &Value) -> bool
pub fn requires_confirmation(&self, tool_name: &str, args: &Value) -> bool
Check if a tool invocation requires confirmation
Sourcepub fn get_matching_rules(&self, tool_name: &str, args: &Value) -> MatchingRules
pub fn get_matching_rules(&self, tool_name: &str, args: &Value) -> MatchingRules
Get matching rules for debugging/logging
Trait Implementations§
Source§impl Clone for PermissionPolicy
impl Clone for PermissionPolicy
Source§fn clone(&self) -> PermissionPolicy
fn clone(&self) -> PermissionPolicy
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for PermissionPolicy
impl Debug for PermissionPolicy
Source§impl Default for PermissionPolicy
impl Default for PermissionPolicy
Source§impl<'de> Deserialize<'de> for PermissionPolicy
impl<'de> Deserialize<'de> for PermissionPolicy
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>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for PermissionPolicy
impl RefUnwindSafe for PermissionPolicy
impl Send for PermissionPolicy
impl Sync for PermissionPolicy
impl Unpin for PermissionPolicy
impl UnsafeUnpin for PermissionPolicy
impl UnwindSafe for PermissionPolicy
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