pub struct IntegratedPermissionManager { /* private fields */ }Expand description
Integrated Permission Manager
Combines the new ToolPermissionManager with the existing PermissionManager
and ToolPermissionStore to provide a unified permission checking interface.
Requirements: 11.1, 11.2
Implementations§
Source§impl IntegratedPermissionManager
impl IntegratedPermissionManager
Sourcepub fn with_legacy_manager(
config_dir: Option<PathBuf>,
legacy_manager: Arc<Mutex<PermissionManager>>,
) -> Self
pub fn with_legacy_manager( config_dir: Option<PathBuf>, legacy_manager: Arc<Mutex<PermissionManager>>, ) -> Self
Create with existing PermissionManager
§Arguments
config_dir- Optional configuration directorylegacy_manager- Reference to existing PermissionManager
Requirements: 11.1
Sourcepub fn with_legacy_systems(
config_dir: Option<PathBuf>,
legacy_manager: Arc<Mutex<PermissionManager>>,
legacy_store: Arc<Mutex<ToolPermissionStore>>,
) -> Self
pub fn with_legacy_systems( config_dir: Option<PathBuf>, legacy_manager: Arc<Mutex<PermissionManager>>, legacy_store: Arc<Mutex<ToolPermissionStore>>, ) -> Self
Create with existing PermissionManager and ToolPermissionStore
§Arguments
config_dir- Optional configuration directorylegacy_manager- Reference to existing PermissionManagerlegacy_store- Reference to existing ToolPermissionStore
Requirements: 11.1, 11.2
Sourcepub fn set_check_legacy_first(&mut self, check_first: bool)
pub fn set_check_legacy_first(&mut self, check_first: bool)
Set whether to check legacy systems first
When true (default), the legacy PermissionManager is checked before the new ToolPermissionManager. This ensures backward compatibility.
Sourcepub fn tool_permission_manager(&self) -> &ToolPermissionManager
pub fn tool_permission_manager(&self) -> &ToolPermissionManager
Get a reference to the underlying ToolPermissionManager
Sourcepub fn tool_permission_manager_mut(&mut self) -> &mut ToolPermissionManager
pub fn tool_permission_manager_mut(&mut self) -> &mut ToolPermissionManager
Get a mutable reference to the underlying ToolPermissionManager
Sourcepub async fn is_allowed(
&self,
tool: &str,
params: &HashMap<String, Value>,
context: &PermissionContext,
) -> PermissionResult
pub async fn is_allowed( &self, tool: &str, params: &HashMap<String, Value>, context: &PermissionContext, ) -> PermissionResult
Check if a tool is allowed to execute
This method integrates both the legacy and new permission systems:
- If check_legacy_first is true, check the legacy PermissionManager first
- If legacy returns a definitive answer (AlwaysAllow or NeverAllow), use it
- Otherwise, fall back to the new ToolPermissionManager
§Arguments
tool- The tool name to checkparams- The tool parameterscontext- The permission context
§Returns
A PermissionResult containing the decision and details
Requirements: 11.1
Sourcepub async fn check_legacy_store(
&self,
tool_request: &ToolRequest,
) -> Option<bool>
pub async fn check_legacy_store( &self, tool_request: &ToolRequest, ) -> Option<bool>
Sourcepub async fn record_legacy_permission(
&self,
tool_request: &ToolRequest,
allowed: bool,
expiry_duration: Option<Duration>,
) -> Result<()>
pub async fn record_legacy_permission( &self, tool_request: &ToolRequest, allowed: bool, expiry_duration: Option<Duration>, ) -> Result<()>
Record a permission decision in the legacy store
§Arguments
tool_request- The tool requestallowed- Whether the tool was allowedexpiry_duration- Optional expiry duration
Requirements: 11.2
Sourcepub async fn check_permission_comprehensive(
&self,
tool: &str,
tool_request: Option<&ToolRequest>,
params: &HashMap<String, Value>,
context: &PermissionContext,
) -> PermissionResult
pub async fn check_permission_comprehensive( &self, tool: &str, tool_request: Option<&ToolRequest>, params: &HashMap<String, Value>, context: &PermissionContext, ) -> PermissionResult
Check permission using both legacy store and new system
This method provides a comprehensive permission check that:
- Checks the legacy ToolPermissionStore for cached decisions
- Falls back to the legacy PermissionManager
- Finally checks the new ToolPermissionManager
§Arguments
tool- The tool nametool_request- Optional tool request for store lookupparams- The tool parameterscontext- The permission context
§Returns
A PermissionResult containing the decision and details
Requirements: 11.1, 11.2
Sourcepub fn set_legacy_store(&mut self, store: Arc<Mutex<ToolPermissionStore>>)
pub fn set_legacy_store(&mut self, store: Arc<Mutex<ToolPermissionStore>>)
Sync permissions from legacy store to new system
This method is useful for migration scenarios where you want to import existing cached permissions into the new system.
Note: This is a one-way sync and doesn’t modify the legacy store.
Requirements: 11.2, 11.5
Sourcepub fn set_legacy_manager(&mut self, manager: Arc<Mutex<PermissionManager>>)
pub fn set_legacy_manager(&mut self, manager: Arc<Mutex<PermissionManager>>)
Set the legacy permission manager
Requirements: 11.1
Sourcepub fn has_legacy_systems(&self) -> bool
pub fn has_legacy_systems(&self) -> bool
Check if legacy systems are configured
Sourcepub fn legacy_permission_manager(
&self,
) -> Option<&Arc<Mutex<PermissionManager>>>
pub fn legacy_permission_manager( &self, ) -> Option<&Arc<Mutex<PermissionManager>>>
Get reference to legacy permission manager if set
Sourcepub fn legacy_permission_store(
&self,
) -> Option<&Arc<Mutex<ToolPermissionStore>>>
pub fn legacy_permission_store( &self, ) -> Option<&Arc<Mutex<ToolPermissionStore>>>
Get reference to legacy permission store if set
Trait Implementations§
Auto Trait Implementations§
impl Freeze for IntegratedPermissionManager
impl !RefUnwindSafe for IntegratedPermissionManager
impl Send for IntegratedPermissionManager
impl Sync for IntegratedPermissionManager
impl Unpin for IntegratedPermissionManager
impl UnsafeUnpin for IntegratedPermissionManager
impl !UnwindSafe for IntegratedPermissionManager
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> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
Source§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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 moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::RequestSource§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
Source§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
Source§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read moreSource§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read moreSource§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
Source§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R,
) -> R
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
Source§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
self, then passes self.as_ref() into the pipe function.Source§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
self, then passes self.as_mut() into the pipe
function.Source§fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
self, then passes self.deref() into the pipe function.Source§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
Source§impl<T> Tap for T
impl<T> Tap for T
Source§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
Borrow<B> of a value. Read moreSource§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
BorrowMut<B> of a value. Read moreSource§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
AsRef<R> view of a value. Read moreSource§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
AsMut<R> view of a value. Read moreSource§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
Deref::Target of a value. Read moreSource§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
Deref::Target of a value. Read moreSource§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
.tap() only in debug builds, and is erased in release builds.Source§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
.tap_mut() only in debug builds, and is erased in release
builds.Source§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
.tap_borrow() only in debug builds, and is erased in release
builds.Source§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
.tap_borrow_mut() only in debug builds, and is erased in release
builds.Source§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
.tap_ref() only in debug builds, and is erased in release
builds.Source§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
.tap_ref_mut() only in debug builds, and is erased in release
builds.Source§fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
.tap_deref() only in debug builds, and is erased in release
builds.