授權流程
Amazon Bedrock AgentCore Gateway 會針對傳入請求評估 Cedar 政策。本節說明授權資訊如何從請求流向政策評估。
請求處理
Amazon Bedrock AgentCore Gateway 會處理每個請求的兩個關鍵資訊:
-
JWT 字符 - 包含有關使用者的 OAuth 宣告:
{ "sub": "12345678-1234-1234-1234-123456789012", "iss": "https://cognito-idp.us-east-1.amazonaws.com/us-east-1_Vg2efaoGO", "username": "refund-agent", "scope": "aws.cognito.signin.user.admin refund:write", "role": "admin", "department": "finance" } -
MCP 工具呼叫請求 - 實際的工具調用:
{ "jsonrpc": "2.0", "id": 1, "method": "tools/call", "params": { "name": "RefundTool___process_refund", "arguments": { "orderId": "12345", "amount": 450, "reason": "Defective product" } } }
Cedar 授權請求
Gateway 從這兩個來源擷取資訊,並建構 Cedar 授權請求。
完成授權請求:
{ "principal": "AgentCore::OAuthUser::\"12345678-1234-1234-1234-123456789012\"", "action": "AgentCore::Action::\"RefundTool___process_refund\"", "resource": "AgentCore::Gateway::\"arn:aws:bedrock-agentcore:us-west-2:123456789012:gateway/refund-gateway\"", "context": { "input": { "orderId": "12345", "amount": 450, "reason": "Defective product" } } }
元件:
- Principal
-
從 JWT 字符的子宣告建立:
AgentCore::OAuthUser::"12345678-1234-1234-1234-123456789012" - Action
-
從工具名稱擷取:
AgentCore::Action::"RefundTool___process_refund" - 資源
-
Gateway 執行個體:
AgentCore::Gateway::"arn:aws:bedrock-agentcore:us-west-2:123456789012:gateway/refund-gateway" - Context
-
包含工具引數:
{ "input": { "orderId": "12345", "amount": 450, "reason": "Defective product" } }
實體存放區 - JWT 宣告會以標籤形式存放在 OAuthUser 實體上:
{ "uid": { "type": "AgentCore::OAuthUser", "id": "12345678-1234-1234-1234-123456789012" }, "attrs": { "id": "12345678-1234-1234-1234-123456789012" }, "tags": { "username": "refund-agent", "iss": "https://cognito-idp.us-east-1.amazonaws.com/us-east-1_Vg2efaoGO", "scope": "aws.cognito.signin.user.admin refund:write", "role": "admin", "department": "finance" } }
政策評估
Cedar 評估:
-
委託人檢查:委託人是否為 OAuthUser? ✓ (相符)
-
動作檢查:動作 RefundTool___process_refund 是否? ✓ (相符)
-
資源檢查:資源是否為退款閘道? ✓ (相符)
-
條件檢查:
-
主體是否有使用者名稱標籤? ✓ (是,來自 JWT)
-
username = "refund-agent" 嗎? ✓ (是)
-
context.input.amount 是否 < 500? ✓ (450 < 500)
-
結果:允許 - 所有檢查都通過,退款已獲得授權。