跨域代理身份PoC——B版:Cedar+Amazon验证权限TBAC
OpenClaw代理代表人类用户(Sarah)执行跨域任务, 通过AGNTCY身份徽章和基于任务的访问进行身份认证 通过亚马逊验证权限评估的Cedar策略执行控制(TBAC)。
建筑
┌─────────────────────────────────────────────────────────────────────┐
│ Human User (Sarah) │
│ delegates task to agent │
└────────────────────────────┬────────────────────────────────────────┘
│
▼
┌─────────────────────────────────────────────────────────────────────┐
│ OpenClaw Agent │
│ │
│ ┌──────────────┐ ┌──────────────────┐ ┌───────────────────────┐ │
│ │ AGNTCY Badge │ │ Okta XAA │ │ Cedar Policy Engine │ │
│ │ (Identity) │ │ (ID-JAG) │ │ (Amazon Verified │ │
│ │ │ │ │ │ Permissions) │ │
│ └──────┬───────┘ └────────┬─────────┘ └──────────┬────────────┘ │
└─────────┼───────────────────┼───────────────────────┼──────────────┘
│ │ │
▼ ▼ ▼
┌──────────────┐ ┌──────────────┐
│ Weather │ │ Slack │
│ MCP Server │ │ MCP Server │
│ │ │ │
│ Domain: │ │ Domain: │
│ api.open- │ │ slack.com │
│ meteo.com │ │ │
└──────────────┘ └──────────────┘图层
1.AGNTCY身份徽章
- 代理从AGNTCY身份服务获得可验证的身份徽章
- 徽章包含:agent_id、委托用户、发卡行DID、签名JWT
- 徽章证明代理人有权代表莎拉行事
2.Okta XAA--身份断言授权授予(ID-JAG)
- 代理使用Okta的ID-JAG流来获取身份断言,然后将它们(使用AGNTCY徽章作为参与者证明)交换为作用域访问令牌
- 每个目标域(Open Meteo、Slack)都会收到一个作用域令牌
- 运行时从AWS Secrets Manager加载的所有凭据。
3.Cedar策略引擎(亚马逊验证权限)
- Cedar策略为每个域定义了细粒度的TBAC规则
- Amazon Verified Permissions评估云中的策略
- 实体模型:
Agent→Action→MCPServer具有范围上下文 - 强制执行的策略:徽章有效性、范围一致性、委托约束
雪松政策
每个MCP服务器域都有自己的Cedar策略文件:
| 文件 | 域 | 关键规则 |
|---|---|---|
weather.cedar | api.open-meeo.com | 使用有效徽章+示波器读取天气数据 |
slack.cedar | slack.com | 使用有效徽章+范围发布消息/阅读频道 |
schema.cedarschema | -- | 实体类型、操作和上下文形状 |
雪松实体模型
namespace XDomainTBAC {
entity Agent { agent_name, delegating_user, badge_id }
entity MCPServer { domain, description }
action "weather.access" appliesTo { principal: Agent, resource: MCPServer }
action "slack.access" appliesTo { principal: Agent, resource: MCPServer }
action "slack.read" appliesTo { principal: Agent, resource: MCPServer }
}项目结构
├── agent/ # Agent orchestrator
│ ├── openclaw_agent.py # Main agent logic
│ ├── task_context.py # Delegation chain tracking
│ └── config.py # Configuration
├── identity/ # AGNTCY Identity layer
│ ├── badge_issuer.py # Badge issuance
│ ├── badge_verifier.py # Badge verification
│ ├── okta_xaa.py # Okta XAA token exchange
│ └── secrets.py # AWS Secrets Manager helpers
├── cedar/ # Cedar policy engine
│ ├── avp_client.py # Amazon Verified Permissions client
│ ├── policy_engine.py # Policy evaluation engine
│ └── policies/ # Cedar policy files
│ ├── weather.cedar
│ ├── slack.cedar
│ └── schema.cedarschema
├── mcp_servers/ # MCP server stubs
│ ├── weather_mcp.py
│ └── slack_mcp.py
├── tests/ # Test suite
├── docker-compose.yml
├── Dockerfile
├── .env.example
└── requirements.txt快速开始
先决条件
- Python 3.9+
- Docker和Docker Compose(可选,适用于全栈)
- Okta开发者账户(用于XAA ID-JAG代币交换)
- 具有亚马逊验证权限的AWS帐户(用于Cedar策略评估)
- AGNTCY身份服务实例
本地开发
# Clone and enter the repo
cd xdomain-openclaw-cedar-poc
# Create virtual environment
python -m venv .venv
source .venv/bin/activate
# Install dependencies
pip install -r requirements.txt
# Copy and configure environment
cp .env.example .env
# Edit .env with your credentials
# Run tests
pytest tests/ -v
# Run the agent
python -m agent.openclaw_agentDocker Compose
# Copy and configure environment
cp .env.example .env
# Start all services
docker-compose up --build
# Run tests in container
docker-compose run openclaw-agent pytest tests/ -v身份验证流程
- 莎拉 将任务委托给OpenClaw代理
- 代理 向AGNTCY身份服务请求身份徽章
- 对于每个MCP服务器(天气、Slack):
- 代理 通过Okta ID-JAG流获得身份断言JWT,然后将其(使用AGNTCY徽章作为参与者证明)交换为特定于域的作用域访问令牌 - 雪松政策引擎 通过AVP评估TBAC授权 - MCP服务器 接收作用域令牌并执行工具调用
- 代理 汇总结果并将其返回给Sarah
运行时从AWS Secrets Manager加载的所有凭据。
委托链示例
Sarah (human)
└─▶ OpenClaw Agent [badge: badge-openclaw-agent-001]
├─▶ Weather MCP [xaa-token: api.open-meteo.com, scopes: weather:read]
└─▶ Slack MCP [xaa-token: slack.com, scopes: slack:chat:write]版本A与版本B
| 特性 | 版本A(AGNTCY) | 版本B(Cedar) |
|---|---|---|
| TBAC引擎 | 身份服务CPMiddleware | 雪松+亚马逊验证权限 |
| 策略格式 | 程序化Python检查 | 声明性Cedar策略 |
| 范围检查 | 基于中间件的设置 | Cedar context.scopes.contains() |
| 云服务 | -- | 亚马逊已验证权限 |
| 策略文件 | -- | .cedar + .cedarschema |
许可证
Apache 2.0——请参阅 许可证.
