政策範圍
範圍定義政策適用的內容。每個 Cedar 政策指定三個元件:
permit( principal is AgentCore::OAuthUser, // WHO is making the request action == AgentCore::Action::"...", // WHAT they want to do resource is AgentCore::Gateway::"..." // WHICH resource they want to access )
實體和命名空間
Cedar 使用實體來代表委託人、動作和資源。AgentCore Gateway 中的所有實體都會使用 AgentCore 命名空間。
實體格式: Namespace::EntityType::"identifier"
Principal
委託人會識別提出授權請求的實體。主體類型取決於如何設定 AgentCore Gateway 進行身分驗證。
OAuth 使用者主體
使用 OAuth 授權時,委託人是 AgentCore::OAuthUser :
principal is AgentCore::OAuthUser
元件:
-
principal- 提出授權請求的實體 -
AgentCore::OAuthUser- 代表 OAuth 驗證使用者的實體類型 -
is- 輸入檢查運算子 (符合任何 OAuthUser 實體)
主體是經 OAuth 驗證的使用者。每個使用者都有來自 JWT 子宣告的唯一 ID。
IAM 實體委託人
使用 AWS_IAM 授權時,委託人是 AgentCore::IamEntity :
principal is AgentCore::IamEntity
元件:
-
principal- 提出授權請求的實體 -
AgentCore::IamEntity- 代表 IAM 驗證來電者的實體類型 -
is- 類型檢查運算子 (符合任何 IamEntity)
IAM 主體具有id屬性,其中包含發起人的 IAM ARN。您可以在此屬性上使用模式比對,以實作帳戶型或角色型存取控制。
Action
動作會指定請求的操作:
action == AgentCore::Action::"RefundTool___process_refund"
元件:
-
action- 正在請求的操作 -
AgentCore::Action::"RefundTool___process_refund"- 特定動作實體 -
==- 完全相符運算子 (僅限此特定動作)
動作代表 MCP AgentCore Gateway 中的工具呼叫。每個工具都有對應的動作實體。
依目標類型的動作名稱
政策中的動作識別符取決於閘道上設定的目標類型:
| Target type (目標類型) | 動作格式 | 範例 |
|---|---|---|
|
MCP |
|
|
|
AgentCore 執行期 |
|
|
|
Proxy (HTTP) |
|
|
多個動作
Cedar 不支援萬用字元動作。必須使用確切的動作識別符 (AgentCore::Action::"ToolName___operation") 明確參考每個動作。若要在單一規則下將多個工具分組,請使用閘道目標 (動作群組) 並針對該目標撰寫政策。
例如,若要僅允許存取名稱開頭為 Read 的工具,您可以建立名為 ReadToolsTarget 的閘道目標,其中包含每個這類工具,然後撰寫如下的政策:
permit( principal, action in AgentCore::Action::"ReadToolsTarget", resource == AgentCore::Gateway::"<gateway-arn>" );
根據政策的效果,這將允許該目標中包含的所有工具。
資源
資源會識別請求的目標:
resource == AgentCore::Gateway::"arn:aws:bedrock-agentcore:us-west-2:123456789012:gateway/refund-gateway"
元件:
-
resource- 請求的目標 -
AgentCore::Gateway- 代表閘道執行個體的實體類型 -
==- 完全相符運算子 (符合此特定的 AgentCore Gateway)
AgentCore Gateway 是路由工具呼叫的 MCP 伺服器。
資源特異性要求
指定一或多個特定動作時,您必須使用特定的 AgentCore Gateway ARNs:
// Required: Specific Gateway ARN for specific action(s) resource == AgentCore::Gateway::"arn:aws:bedrock-agentcore:us-west-2:123456789012:gateway/refund-gateway"
這適用於:
-
單一動作:
action == AgentCore::Action::"ToolName" -
多個特定動作:
action in [AgentCore::Action::"Tool1", AgentCore::Action::"Tool2"]
僅在符合任何動作時使用類型檢查:
// For policies covering any action (not specific tools) resource is AgentCore::Gateway
範例:
// Blocks all actions forbid(principal, action, resource); // Allow any CallTool action permit(principal, action in AgentCore::Action::"CallTool", resource is AgentCore::Gateway::"arn:aws:bedrock-agentcore:us-west-2:123456789012:gateway/refund-gateway");
特定 AgentCore Gateway ARNs提供:
-
AgentCore Gateway 執行個體之間的安全隔離
-
生產和開發環境的分隔
-
每個 AgentCore Gateway 的精細存取控制