显示 HN:OneCLI – 用 Rust 编写的 AI Agent 的 Vault
Show HN: OneCLI – Vault for AI Agents in Rust

原始链接: https://github.com/onecli/onecli

## OneCLI:AI 代理的安全凭证管理 OneCLI 是一个开源网关,旨在安全地管理 AI 代理使用的 API 凭证。它不将敏感密钥直接嵌入代理中,而是提供一个集中存储和控制访问的位置。 其工作原理是:代理使用占位符密钥,OneCLI 基于 Rust 的网关会拦截 HTTP 请求,将这些占位符替换为正确的解密凭证,*而无需*将真实密钥暴露给代理。这利用了 AES-256-GCM 加密和模式匹配(主机和路径)来实现安全、有针对性的注入。 OneCLI 提供了一个 Web 控制面板,用于管理代理、密钥和权限,并支持单用户和团队(Google OAuth)身份验证。它设计为通过 Docker 轻松本地部署,最初不需要外部数据库,并且还可以与 PostgreSQL 集成。 本质上,OneCLI 简化了 AI 代理的安全性和访问控制,为凭证提供了一个统一的管理点,并提供了对代理 API 使用情况的宝贵见解。

## OneCLI:为AI代理提供安全的密钥 OneCLI是一个新的开源工具,旨在解决AI代理被授予直接访问敏感API密钥的安全风险。它使用Rust构建,并带有Next.js仪表盘,充当代理和服务的中间层。 OneCLI不向代理提供真实的凭证,而是使用占位符密钥。当代理发出请求时,OneCLI会从其加密(AES-256-GCM)的密钥库中安全地将占位符替换为实际密钥,然后转发请求。这确保了代理永远不会直接处理敏感信息。 OneCLI打包成一个单独的Docker容器,并嵌入Postgres,可以通过标准的HTTPS_PROXY设置与各种代理框架协同工作。开发者目前正专注于添加访问策略和审计日志以增强控制。 该项目采用Apache-2.0许可,并可在GitHub上找到 ([https://github.com/onecli/onecli](https://github.com/onecli/onecli))。一个担忧是,由于占位符密钥,安全扫描工具可能会出现误报。
相关文章

原文
OneCLI

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

Website · Docs


How OneCLI works

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 proxy 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 proxy handles the swap.

OneCLI Architecture
  • Rust Gateway: fast HTTP gateway that intercepts outbound requests and injects credentials. Agents authenticate with access tokens via Proxy-Authorization headers.
  • 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.

The fastest way to run OneCLI locally (no external database or config needed):

docker run --pull always -p 10254:10254 -p 10255:10255 -v onecli-data:/app/data ghcr.io/onecli/onecli

Open http://localhost:10254, create an agent, add your secrets, and point your agent's HTTP gateway to localhost:10255.

git clone https://github.com/onecli/onecli.git
cd onecli/docker
docker compose up
  • 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
  • No external dependencies: runs with embedded PGlite (or bring your own 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
apps/
  web/            # Next.js app (dashboard + API, port 10254)
  proxy/          # Rust gateway (credential injection, port 10255)
packages/
  db/             # Prisma ORM + migrations + PGlite
  ui/             # Shared UI components (shadcn/ui)
docker/
  Dockerfile      # Single-container build (gateway + web + PGlite)
  docker-compose.yml
  • mise (installs Node.js, pnpm, and other tools)
  • Rust (for the gateway)
mise install
pnpm install
cp .env.example .env
pnpm db:generate
pnpm db:init-dev
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: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 Embedded PGlite
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.

Apache-2.0

联系我们 contact @ memedata.com