pub struct CedarAuthorization { /* private fields */ }Expand description
Authorizes each tool call against Cedar policies (CedarAuthorization).
A denial is the tool result DENIED: Access denied by Cedar policy[: <details>]. The per-tool
call counts behind context.session.call_count are kept in each agent’s app state under
CEDAR_AUTHORIZATION_STATE_KEY, so agents that share one handler (such as a parent and its
subagents) each have their own budget; a denied call does not count.
Implementations§
Source§impl CedarAuthorization
impl CedarAuthorization
Sourcepub fn new(config: CedarAuthorizationConfig) -> Result<Self>
pub fn new(config: CedarAuthorizationConfig) -> Result<Self>
A handler with these settings; policies are parsed and validated now.
§Errors
Both a principal and a resolver; a missing policy, schema or entity file
(Cedar policy file not found: <path>); invalid policies (Invalid Cedar policy: ..);
policies that fail schema validation (Cedar policy validation failed: ..); a failed
schema generation (Schema generation failed: ..); an entity without a uid.
Sourcepub fn reset_call_counts(&self, app_state: &StateStore)
pub fn reset_call_counts(&self, app_state: &StateStore)
Clears the agent’s rate-limit call counts. Pass the agent’s app_state().
Trait Implementations§
Source§impl Debug for CedarAuthorization
impl Debug for CedarAuthorization
Source§impl InterventionHandler for CedarAuthorization
impl InterventionHandler for CedarAuthorization
Source§fn name(&self) -> &str
fn name(&self) -> &str
Confirm raises.Source§fn on_error(&self) -> OnError
fn on_error(&self) -> OnError
OnError::Throw.Source§fn before_tool_call<'life0, 'life1, 'async_trait>(
&'life0 self,
event: &'life1 mut BeforeToolCallEvent,
) -> Pin<Box<dyn Future<Output = InterventionResult<BeforeToolCallEvent>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn before_tool_call<'life0, 'life1, 'async_trait>(
&'life0 self,
event: &'life1 mut BeforeToolCallEvent,
) -> Pin<Box<dyn Future<Output = InterventionResult<BeforeToolCallEvent>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Source§fn before_invocation<'a, 'life0, 'life1, 'async_trait>(
&'life0 self,
_event: &'life1 mut BeforeInvocationEvent<'a>,
) -> Pin<Box<dyn Future<Output = InterventionResult<BeforeInvocationEvent<'a>>> + Send + 'async_trait>>where
Self: 'async_trait,
'a: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn before_invocation<'a, 'life0, 'life1, 'async_trait>(
&'life0 self,
_event: &'life1 mut BeforeInvocationEvent<'a>,
) -> Pin<Box<dyn Future<Output = InterventionResult<BeforeInvocationEvent<'a>>> + Send + 'async_trait>>where
Self: 'async_trait,
'a: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Source§fn after_tool_call<'life0, 'life1, 'async_trait>(
&'life0 self,
_event: &'life1 mut AfterToolCallEvent,
) -> Pin<Box<dyn Future<Output = InterventionResult<AfterToolCallEvent>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn after_tool_call<'life0, 'life1, 'async_trait>(
&'life0 self,
_event: &'life1 mut AfterToolCallEvent,
) -> Pin<Box<dyn Future<Output = InterventionResult<AfterToolCallEvent>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Source§fn before_model_call<'a, 'life0, 'life1, 'async_trait>(
&'life0 self,
_event: &'life1 mut BeforeModelCallEvent<'a>,
) -> Pin<Box<dyn Future<Output = InterventionResult<BeforeModelCallEvent<'a>>> + Send + 'async_trait>>where
Self: 'async_trait,
'a: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn before_model_call<'a, 'life0, 'life1, 'async_trait>(
&'life0 self,
_event: &'life1 mut BeforeModelCallEvent<'a>,
) -> Pin<Box<dyn Future<Output = InterventionResult<BeforeModelCallEvent<'a>>> + Send + 'async_trait>>where
Self: 'async_trait,
'a: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Source§fn after_model_call<'a, 'life0, 'life1, 'async_trait>(
&'life0 self,
_event: &'life1 mut AfterModelCallEvent<'a>,
) -> Pin<Box<dyn Future<Output = InterventionResult<AfterModelCallEvent<'a>>> + Send + 'async_trait>>where
Self: 'async_trait,
'a: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn after_model_call<'a, 'life0, 'life1, 'async_trait>(
&'life0 self,
_event: &'life1 mut AfterModelCallEvent<'a>,
) -> Pin<Box<dyn Future<Output = InterventionResult<AfterModelCallEvent<'a>>> + Send + 'async_trait>>where
Self: 'async_trait,
'a: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Auto Trait Implementations§
impl !Freeze for CedarAuthorization
impl !RefUnwindSafe for CedarAuthorization
impl !UnwindSafe for CedarAuthorization
impl Send for CedarAuthorization
impl Sync for CedarAuthorization
impl Unpin for CedarAuthorization
impl UnsafeUnpin for CedarAuthorization
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
§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> ⓘ
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 more