微算力 · API 导航与自营网关
API 接入 EN
未登录登录
🚂

安全连接 Rails 数据网关,自动化运营简报

Ruby On Rails Gateway · v1.0.0
办公 安全 A 级 作者 jessewaites 公开目录收录
1k 下载 2 安装 5.1k 收藏 9 浏览

简介

用于配置和调用 Rails Agent Gateway 的 OpenClaw 端技能,支持安全令牌验证、数据拉取和自动化报告生成。

原始描述

Configure and operate a Ruby On Rails Agent Gateway integration from the OpenClaw side for briefing pull workflows. Use when setting up OpenClaw to read app...

通过你的 Agent 添加

安装目录:rails-agent-gateway/(目录名取自 SKILL.md 的 frontmatter name,不是 URL 里的 slug)。

点「快速安装」复制一段指令贴给你的 Agent:它会先下载到 /tmp、把文件清单和校验值给你看,你确认之后才解压安装。不会一步装完、也不改系统其它位置。

或者手动安装

Claude Code~/.claude/skills/ruby-on-rails-gateway/
Codex CLI~/.codex/skills/ruby-on-rails-gateway/
DeepSeek Harness~/.agents/skills/ruby-on-rails-gateway/

包是「根级 SKILL.md + 作者附带的文件」,解压到上面的 <slug>/ 目录即可; 目录名不用换,也不要把包直接解压到 skills 根目录。 技能申请的权限由作者决定:装之前先看清单里有没有脚本、它会读写什么。

中文使用说明 来自收录源

核心用法

Rails Agent Gateway 技能是 OpenClaw 与 Ruby on Rails 应用之间建立安全数据通道的桥梁。该技能与 agent_gateway gem 配合使用,通过标准 REST API 从 Rails 应用的 /agent-gateway/:secret/briefing 端点拉取聚合数据。

典型工作流程

  1. 环境验证:检查 AGENT_GATEWAY_TOKEN 和 AGENT_GATEWAY_SECRET 是否已配置
  2. 连通性测试:执行非破坏性简报拉取,验证双因素认证(路径密钥 + Bearer Token)
  3. 数据获取:按时间窗口(1d/7d/30d/90d/1y/all)和资源类型(users/orders 等)拉取数据
  4. 结果汇总:生成记录计数、聚合统计(count/sum/avg)和最新记录快照
  5. 自动化准备:输出适合 cron 任务或 CI/CD 管道的命令片段

认证机制

采用双层安全设计:

  • 路径密钥(Path Secret):嵌入 URL 中,错误返回 404(隐匿端点存在性)
  • Bearer Token:通过 Authorization 头部传输,错误返回 401

两者均使用 secure_compare 时序安全比较,有效防御时序攻击。

调用方式

推荐优先使用本地辅助脚本:

/home/node/.openclaw/workspace/scripts/rails-gateway-briefing --period 7d --resources users,orders

或直接 curl(生产环境需妥善保管令牌):

curl -H "Authorization: Bearer $AGENT_GATEWAY_TOKEN" \
  "https://myapp.com/agent-gateway/$AGENT_GATEWAY_SECRET/briefing?period=7d"

显著优点

  • 标准化集成:遵循 RESTful 设计,与 Rails 生态无缝兼容
  • 安全设计:双因素认证 + 时序安全比较 + 令牌不在输出中暴露
  • 灵活查询:支持时间窗口、资源筛选、聚合计算和记录限制
  • 自动化友好:输出格式适合脚本化调用和定时任务

潜在局限

  • 依赖外部 gem:Rails 端必须安装并配置 agent_gateway,无法独立工作
  • 只读限制:设计为拉取(pull)模式,不支持写入操作
  • 网络依赖:需要 Rails 应用可公开访问,内网部署需额外配置
  • 令牌管理:环境变量依赖增加了运维复杂度,轮转令牌时需同步更新两端

适合人群

  • 使用 Rails 作为后端、需要向 OpenClaw 暴露结构化数据的开发团队
  • 需要自动化生成运营报告或数据摘要的技术运维人员
  • 希望在不开放数据库直接访问的前提下实现安全数据通道的架构师

常规风险

  • 令牌泄露风险:Bearer Token 具备完整读取权限,需严格控制环境变量访问
  • 端点探测:尽管 404 错误隐藏端点,但 URL 模式仍可能被猜测
  • 数据范围失控:period=all 或大量资源组合可能导致响应过大,建议始终使用 --latest 限制
  • 依赖维护:gem 版本更新时需同步检查兼容性

安全承诺

  • 绝不回显或记录 live token
  • 命令示例中自动脱敏敏感参数
  • 仅执行只读操作(briefing 端点),无写权限

注意:本技能需与 Rails 端的 agent_gateway gem 配合使用,单方面配置无法生效。

技能正文


name: rails-agent-gateway description: Configure and operate a Ruby On Rails Agent Gateway integration from the OpenClaw side for briefing pull workflows. Use when setting up OpenClaw to read app data through a Rails /agent-gateway/:secret/briefing endpoint, validating tokens/URL env vars, testing connectivity, and generating summary pulls for reports or automations.

Rails Agent Gateway

This skill works in tandem with the agent_gateway Ruby gem, a mountable Rails engine that must be installed and configured on the Rails side (gem "agent_gateway" + initializer). This skill handles the OpenClaw-side setup and usage for pulling data from that endpoint.

Quick Workflow

  1. Confirm required env vars are available.
  2. Validate endpoint connectivity with a non-destructive briefing fetch.
  3. Pull briefing data for a selected period/resources.
  4. Summarize result counts, aggregations, and latest records.
  5. If requested, prepare commands suitable for cron/automation.

Required Environment

Require these variables before any live fetch:

  • AGENT_GATEWAY_TOKEN (bearer token — set in the Rails app initializer as c.auth_token)
  • AGENT_GATEWAY_SECRET (path secret — set as c.path_secret)

The OpenClaw helper script may also read:

  • RAILS_GATEWAY_URL (full /briefing URL, e.g. https://myapp.com/agent-gateway/<secret>/briefing)
  • RAILS_GATEWAY_TOKEN (maps to bearer token)

If env vars are missing, stop and show the exact export commands needed.

Authentication

The gem uses two-layer auth:

  1. Path secret — embedded in the URL (/agent-gateway/<secret>/briefing). Wrong value returns 404 (endpoint appears nonexistent).
  2. Bearer token — sent via Authorization header. Wrong/missing value returns 401.

Both are compared using timing-safe secure_compare.

Command Patterns

Direct curl

curl -H "Authorization: Bearer $AGENT_GATEWAY_TOKEN" \
  "https://myapp.com/agent-gateway/$AGENT_GATEWAY_SECRET/briefing?period=7d&resources=users,orders"

Helper script

Prefer the local helper script when present:

/home/node/.openclaw/workspace/scripts/rails-gateway-briefing --period 7d

With explicit env vars:

RAILS_GATEWAY_URL='https://myapp.com/agent-gateway/<secret>/briefing' \
RAILS_GATEWAY_TOKEN='***' \
/home/node/.openclaw/workspace/scripts/rails-gateway-briefing --period 7d --resources users,orders

Query Parameters

Param Description Example
period Time window: 1d, 7d, 30d, 90d, 1y, all ?period=30d
resources Comma-separated resource keys ?resources=users,orders
latest Override latest count for all resources ?latest=10

Resource-Scoped Pulls

Resources are configured per-app via the gem's DSL. Common examples:

  • --resources users
  • --resources orders

Use --latest N to cap detailed rows while keeping counts.

The gem DSL also supports aggregations (count, sum, avg) on numeric columns — these appear in the response alongside count and latest.

Safety Rules

  • Never print or echo live tokens in user-visible output.
  • Redact secrets in pasted commands.
  • Do not perform external write actions unless explicitly asked.
  • Keep pulls read-only (briefing endpoint usage only).

Troubleshooting

If calls fail:

  1. Confirm helper script exists and is executable.
  2. Confirm endpoint URL includes /agent-gateway/<secret>/briefing.
  3. Confirm bearer token is current (AGENT_GATEWAY_TOKEN).
  4. Check two-layer auth: 404 = bad path secret, 401 = bad bearer token.
  5. Retry with minimal scope (--resources users --period 7d --latest 1).
  6. Report exact error class (auth/network/format), then propose a fix.

For reusable command snippets and output interpretation, read references/usage.md.

正文来自原始发布页, 版权归作者所有,许可未标注。 权利人认为有不妥,可申请下架。

标签

ruby-on-railsapi-integrationdata-gatewaybearer-tokenrest-apicron-automationread-onlyenvironment-variables

同类 Skill