pub struct SecurityMiddleware { /* private fields */ }Expand description
Middleware that checks tool execution against the Authorizer.
Installed in the BeforeTool phase. For each tool call:
- Infers the required capability from tool name + params.
- Checks with the Authorizer.
- Blocks if denied.
Implementations§
Source§impl SecurityMiddleware
impl SecurityMiddleware
Sourcepub fn new(authorizer: Arc<Authorizer>) -> Self
pub fn new(authorizer: Arc<Authorizer>) -> Self
Create a new security middleware with the given authorizer.
Sourcepub fn required_capability(
tool_name: &str,
params: &Value,
) -> Option<Capability>
pub fn required_capability( tool_name: &str, params: &Value, ) -> Option<Capability>
Infer the capability required for a tool call from its name and params.
Trait Implementations§
Source§impl Middleware for SecurityMiddleware
impl Middleware for SecurityMiddleware
Source§fn phases(&self) -> Vec<MiddlewarePhase>
fn phases(&self) -> Vec<MiddlewarePhase>
Phases at which this middleware wishes to be invoked.
Source§fn handle<'a>(
&'a self,
ctx: &'a MiddlewareContext,
) -> Pin<Box<dyn Future<Output = MiddlewareResult> + Send + 'a>>
fn handle<'a>( &'a self, ctx: &'a MiddlewareContext, ) -> Pin<Box<dyn Future<Output = MiddlewareResult> + Send + 'a>>
Inspect the context for the current phase and return a result.
Auto Trait Implementations§
impl !RefUnwindSafe for SecurityMiddleware
impl !UnwindSafe for SecurityMiddleware
impl Freeze for SecurityMiddleware
impl Send for SecurityMiddleware
impl Sync for SecurityMiddleware
impl Unpin for SecurityMiddleware
impl UnsafeUnpin for SecurityMiddleware
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