Show HN:OneCLI——让密钥不进入 AI Agent 的开源凭证网关
英文标题:🔶 Show HN: OneCLI – OSS credential gateway that keeps secrets out of AI agents
OneCLI 是一个开源凭证网关,部署在 AI Agent 与其调用的外部服务之间,可在请求转发时透明注入真实 API 凭证。开发者只需在 OneCLI 中集中保存和管理密钥,并向 Agent 提供占位密钥,Agent 无需接触真实机密。该项目采用 Rust 构建 HTTP 网关,支持 AES-256-GCM 加密、按主机与路径匹配凭证、多 Agent 权限隔离,以及本地单用户和 Google OAuth 团队两种认证模式。对开发团队而言,它提供了集中化的密钥轮换、访问控制和 Agent 调用管理能力,并可集成 Bitwarden 等密码管理器实现按需注入。
354.3 KB
323.4 KB
1.5 MB
1.4 MB
136.0 KB
中文

面向 AI Agent 的秘密金库。
一次存储,随处注入。Agent 永远看不到密钥。

OneCLI 是一个位于 AI Agent 与其调用服务之间的开源网关。你无需将 API 密钥硬编码到每个 Agent 中,而是只需在 OneCLI 中存储一次凭证,网关便会透明地注入这些凭证。Agent 永远看不到秘密。
**我们为何构建它:**AI Agent 需要调用数十种 API,但向每个 Agent 提供原始凭证会带来安全风险。OneCLI 通过一个统一处理认证的网关解决这一问题,因此你可以在一个位置管理访问权限、轮换密钥,并查看每个 Agent 的操作。
**工作原理:**你将真实 API 凭证存储在 OneCLI 中,并向 Agent 提供占位密钥(例如 FAKE_KEY)。当 Agent 通过网关发起 HTTP 调用时,OneCLI 网关会将请求匹配到正确的凭证,用 REAL_KEY 替换 FAKE_KEY,解密凭证后将其注入出站请求。Agent 从不接触真实秘密;它只需发起普通 HTTP 调用,网关会处理替换工作。
- Rust 网关:快速的 HTTP 网关,可拦截出站请求并注入凭证。Agent 通过
Proxy-Authorization请求头中的访问令牌进行认证。 - Web 控制台:用于管理 Agent、秘密和权限的 Next.js 应用。它提供 API,供网关解析每个请求应注入哪些凭证。
- 秘密存储:使用 AES-256-GCM 加密的凭证存储。秘密仅在请求时解密,通过主机和路径模式匹配,并由网关以请求头或 URL 查询参数的形式注入。
在本地运行 OneCLI 的最快方式:
curl -fsSL https://onecli.sh/install | sh
或者,如果你希望手动运行:
git clone https://github.com/onecli/onecli.git
cd onecli
docker compose -f docker/docker-compose.yml up -d --wait
打开 http://localhost:10254,创建一个 Agent,添加你的秘密,然后将 Agent 的 HTTP 网关指向 localhost:10255。
快速开始会以 本地模式(单用户、无需登录)运行 OneCLI,因此不需要
.env或NEXTAUTH_SECRET。如需为多用户启用 Google OAuth,请设置NEXTAUTH_SECRET和 Google 凭证(参见配置)。
-
透明凭证注入:Agent 发起普通 HTTP 调用,网关负责认证
-
加密秘密存储:静态数据采用 AES-256-GCM 加密,仅在请求时解密
-
主机与路径匹配:通过模式匹配将秘密路由至正确的 API 端点
-
多 Agent 支持:每个 Agent 都拥有带有范围限定权限的独立访问令牌
-
便捷设置:
curl -fsSL https://onecli.sh/install | sh可启动全部服务(应用 + PostgreSQL) -
两种认证模式:本地使用的单用户模式(无需登录),或面向团队的 Google OAuth
-
Rust 网关:快速、内存安全的 HTTP 网关,支持 HTTPS 的 MITM 拦截
-
Vault 集成:连接 Bitwarden(或其他密码管理器),按需注入凭证,无需在服务器上存储秘密
apps/ web/ # Next.js app (dashboard + API, port 10254) gateway/ # Rust gateway (credential injection, port 10255) packages/ db/ # Prisma ORM + migrations ui/ # Shared UI components (shadcn/ui) docker/ Dockerfile # App image (gateway + web) docker-compose.yml
-
mise(安装 Node.js、pnpm 和其他工具)
-
Rust(用于网关)
-
Docker(用于 PostgreSQL)
mise install pnpm install cp .env.example .env pnpm db:generate pnpm db:up # Start PostgreSQL pnpm db:migrate # Apply migrations pnpm dev
控制台地址为 http://localhost:10254,网关地址为 http://localhost:10255。
| 命令 | 说明 |
|---|---|
pnpm dev |
以开发模式启动 Web 与网关 |
pnpm build |
生产构建 |
pnpm check |
执行 Lint、类型检查和格式检查 |
pnpm db:up |
启动 PostgreSQL(Docker) |
pnpm db:down |
停止 PostgreSQL |
pnpm db:generate |
生成 Prisma 客户端 |
pnpm db:migrate |
运行数据库迁移 |
pnpm db:studio |
打开 Prisma Studio |
本地开发时,所有环境变量均为可选:
| 变量 | 说明 | 默认值 |
|---|---|---|
DATABASE_URL |
PostgreSQL 连接字符串 | 参见 .env.example |
NEXTAUTH_SECRET |
启用 Google OAuth(多用户) | 单用户模式 |
GOOGLE_CLIENT_ID |
Google OAuth 客户端 ID | — |
GOOGLE_CLIENT_SECRET |
Google OAuth 客户端密钥 | — |
SECRET_ENCRYPTION_KEY |
AES-256-GCM 加密密钥 | 自动生成 |
English / 原文

The secret vault for AI agents.
Store once. Inject anywhere. Agents never see the keys.

OneCLI is an open-source gateway that sits between your AI agents and the services they call. Instead of baking API keys into every agent, you store credentials once in OneCLI and the gateway injects them transparently. Agents never see the secrets.
Why we built it: AI agents need to call dozens of APIs, but giving each agent raw credentials is a security risk. OneCLI solves this with a single gateway that handles auth, so you get one place to manage access, rotate keys, and see what every agent is doing.
How it works: You store your real API credentials in OneCLI and give your agents placeholder keys (e.g. FAKE_KEY). When an agent makes an HTTP call through the gateway, the OneCLI gateway matches the request to the right credentials, swaps the FAKE_KEY for the REAL_KEY, decrypts them, and injects them into the outbound request. The agent never touches the real secrets. It just makes normal HTTP calls and the gateway handles the swap.
- Rust Gateway : fast HTTP gateway that intercepts outbound requests and injects credentials. Agents authenticate with access tokens via
Proxy-Authorizationheaders. - Web Dashboard : Next.js app for managing agents, secrets, and permissions. Provides the API the gateway uses to resolve which credentials to inject for each request.
- Secret Store : AES-256-GCM encrypted credential storage. Secrets are decrypted only at request time, matched by host and path patterns, and injected by the gateway as headers or URL query parameters.
The fastest way to run OneCLI locally:
curl -fsSL https://onecli.sh/install | sh
Or, if you prefer to run it manually:
git clone https://github.com/onecli/onecli.git
cd onecli
docker compose -f docker/docker-compose.yml up -d --wait
Open http://localhost:10254 , create an agent, add your secrets, and point your agent's HTTP gateway to localhost:10255.
The Quick Start runs OneCLI in local mode (single-user, no login), so no
.envorNEXTAUTH_SECRETis required. To enable Google OAuth for multiple users, setNEXTAUTH_SECRETand the Google credentials (see Configuration).
-
Transparent credential injection : agents make normal HTTP calls, the gateway handles auth
-
Encrypted secret storage : AES-256-GCM encryption at rest, decrypted only at request time
-
Host & path matching: route secrets to the right API endpoints with pattern matching
-
Multi-agent support : each agent gets its own access token with scoped permissions
-
Easy setup :
curl -fsSL https://onecli.sh/install | shstarts everything (app + PostgreSQL) -
Two auth modes : single-user (no login) for local use, or Google OAuth for teams
-
Rust gateway : fast, memory-safe HTTP gateway with MITM interception for HTTPS
-
Vault integration : connect Bitwarden (or other password managers) for on-demand credential injection without storing secrets on the server
apps/ web/ # Next.js app (dashboard + API, port 10254) gateway/ # Rust gateway (credential injection, port 10255) packages/ db/ # Prisma ORM + migrations ui/ # Shared UI components (shadcn/ui) docker/ Dockerfile # App image (gateway + web) docker-compose.yml
-
mise (installs Node.js, pnpm, and other tools)
-
Rust (for the gateway)
-
Docker (for PostgreSQL)
mise install pnpm install cp .env.example .env pnpm db:generate pnpm db:up # Start PostgreSQL pnpm db:migrate # Apply migrations pnpm dev
Dashboard at http://localhost:10254 , gateway at http://localhost:10255.
| Command | Description |
|---|---|
pnpm dev |
Start web + gateway in dev mode |
pnpm build |
Production build |
pnpm check |
Lint + types + format |
pnpm db:up |
Start PostgreSQL (Docker) |
pnpm db:down |
Stop PostgreSQL |
pnpm db:generate |
Generate Prisma client |
pnpm db:migrate |
Run database migrations |
pnpm db:studio |
Open Prisma Studio |
All environment variables are optional for local development:
| Variable | Description | Default |
|---|---|---|
DATABASE_URL |
PostgreSQL connection string | See .env.example |
NEXTAUTH_SECRET |
Enables Google OAuth (multi-user) | Single-user mode |
GOOGLE_CLIENT_ID |
Google OAuth client ID | — |
GOOGLE_CLIENT_SECRET |
Google OAuth client secret | — |
SECRET_ENCRYPTION_KEY |
AES-256-GCM encryption key | Auto-generated |
We welcome contributions! Please read our Contributing Guide and Code of Conduct before getting started.