Skip to content

feat(cli): support tenant identity defaults and overrides#1019

Merged
qin-ctx merged 1 commit intomainfrom
support_tenant_cli
Mar 27, 2026
Merged

feat(cli): support tenant identity defaults and overrides#1019
qin-ctx merged 1 commit intomainfrom
support_tenant_cli

Conversation

@zhoujh01
Copy link
Copy Markdown
Collaborator

@zhoujh01 zhoujh01 commented Mar 27, 2026

Summary

这个 PR 为 Rust CLI 补齐了多租户身份能力,并同步更新了认证/配置文档,使 CLI、ovcli.conf 和服务端当前认证模型保持一致。

  • 为 Rust CLI 的 ovcli.conf 增加了 account 和 user 字段,并保留现有 agent_id
  • 为 CLI 增加了全局身份覆盖参数:
    • --account
    • --user
    • --agent-id
  • Rust HTTP 客户端现在会发送以下请求头:
    • X-OpenViking-Account
    • X-OpenViking-User
    • X-OpenViking-Agent
  • 明确身份优先级为:
    • CLI 参数 > ovcli.conf > 服务端默认行为/服务端解析
  • 更新中英文文档,补充说明:
    • trusted 认证模式
    • server.auth_mode = "api_key" | "trusted"
    • ovcli.conf 中多租户身份字段的含义
    • root_api_key / trusted 模式下的用法示例
  • 更新 CLI 配置示例文件,加入多租户身份字段

主要行为变化

  • 现在可以在 ovcli.conf 中配置默认身份:

{
"url": "http://localhost:1933",
"api_key": "your-key",
"account": "acme",
"user": "alice",
"agent_id": "assistant-1"
}

  • 也可以在单次命令里显式覆盖:

openviking --account acme --user alice --agent-id assistant-1 ls viking://resources

  • 对于普通 user key 场景,account / user 仍然是可选的,因为服务端可以从 key 反查
  • 对于 root_api_key 访问租户级接口,或者 trusted 模式,CLI / ovcli.conf 现在可以稳定地携带 account / user

修改文件

  • Rust CLI 实现
    • crates/ov_cli/src/config.rs
    • crates/ov_cli/src/client.rs
    • crates/ov_cli/src/main.rs
  • CLI 文档与示例
    • crates/ov_cli/README.md
    • examples/ovcli.conf.example
  • 认证 / 配置文档
    • docs/en/guides/04-authentication.md
    • docs/zh/guides/04-authentication.md
    • docs/en/guides/01-configuration.md
    • docs/zh/guides/01-configuration.md
    • docs/en/api/01-overview.md
    • docs/zh/api/01-overview.md

Test Plan

已执行:

cargo test -p ov_cli

覆盖内容包括:

  • ovcli.conf 能正确解析 account / user / agent_id
  • CLI 能正确解析全局身份参数
  • CLI 参数能覆盖配置文件中的身份字段
  • HTTP 客户端会正确发送多租户身份请求头

Commit

当前最新提交:

2ad4236

@github-actions
Copy link
Copy Markdown

Failed to generate code suggestions for PR

@qin-ctx qin-ctx merged commit c5033b0 into main Mar 27, 2026
23 checks passed
@qin-ctx qin-ctx deleted the support_tenant_cli branch March 27, 2026 03:35
@github-project-automation github-project-automation bot moved this from Backlog to Done in OpenViking project Mar 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants