Skip to main content

Module cedar

Module cedar 

Source
Expand description

Cedar policy authorization of tool calls.

CedarAuthorization evaluates Cedar policies before each tool call. A call maps to the request principal, Action::"<tool name>", Resource::"agent" and the context { input: <tool input>, session: { hour_utc, call_count, ..enricher } }. It runs the native cedar-policy engine through the JSON interface of Cedar’s WebAssembly build, so decisions and messages match the other Strands SDKs.

use strands::Agent;
use strands::testing::MockModel;
use strands::vended_interventions::cedar::{CedarAuthorization, CedarAuthorizationConfig};

let cedar = CedarAuthorization::new(CedarAuthorizationConfig {
    policies: r#"permit(principal, action == Action::"search", resource);"#.into(),
    ..Default::default()
})?;
let agent = Agent::builder()
    .model(MockModel::new())
    .interventions([cedar])
    .printer(false)
    .build()?;

Structs§

CedarAuthorization
Authorizes each tool call against Cedar policies (CedarAuthorization).
CedarAuthorizationConfig
Settings of a CedarAuthorization (CedarAuthorizationConfig).
CedarAuthorizationConfigBuilder
Use builder syntax to set the inputs and finish with build().
ContextEnricher
Adds fields to context.session; it cannot overwrite hour_utc or call_count.
ContextEnricherInput
What a ContextEnricher gets.
PrincipalResolver
Resolves the principal from the invocation state; None denies.
ToolDefinition
A tool for schema generation, in the MCP tool shape (ToolDefinition).
TypeAndId
A Cedar entity reference (TypeAndId).

Enums§

CedarEntities
Entity data: Cedar entity JSON, or the path of a .json file.

Constants§

CEDAR_AUTHORIZATION_STATE_KEY
The app-state key of the per-tool call counts.