审计日志提供了对 ATH 实现所做的所有授权决策的可见性。这对于安全监控、合规性和事件响应至关重要。

日志格式

实现者应当(SHOULD)使用以下结构记录所有授权决策:
{
  "timestamp": "2026-04-10T12:00:00Z",
  "event": "access_granted",
  "agent_id": "https://travel-agent.example.com/.well-known/agent.json",
  "user_id": "user-12345",
  "provider_id": "example-mail",
  "requested_scopes": ["mail:read", "mail:send"],
  "effective_scopes": ["mail:read"],
  "denied_scopes": ["mail:send"],
  "denial_reason": "agent not approved for mail:send"
}

需要记录的事件

事件触发时机
agent_registered代理注册成功
agent_registration_denied代理注册被拒绝
attestation_failed代理证明 JWT 验证失败
authorization_startedOAuth 流程已发起
access_granted令牌已签发,包含有效权限范围
access_denied令牌请求被拒绝
token_revoked令牌已被撤销
proxy_request通过代理转发进行了 API 调用
scope_violation代理尝试访问其令牌范围之外的权限

监控建议

  • 对同一代理反复出现的 attestation_failed 事件发出告警
  • proxy_request 事件中的异常模式(频率、时间、权限使用)发出告警
  • 定期审查 agent_registered 事件,以发现未经授权的注册尝试
  • 跟踪 scope_violation 事件以检测可能被入侵的代理