Skip to content

refactor(auth): remove unauthenticated dev mode - #6354

Open
sponge225 wants to merge 15 commits into
volcengine:mainfrom
sponge225:sponge/remove-dev-auth-mode
Open

sponge225 wants to merge 15 commits into
volcengine:mainfrom
sponge225:sponge/remove-dev-auth-mode

Conversation

@sponge225

@sponge225 sponge225 commented Oct 20, 2026 •

Copy link
Copy Markdown
Collaborator

Description

本 PR 移除 OpenViking 生产运行时中的 dev 认证模式,并把默认认证路径收敛到显式认证。

此前,当 server.auth_mode 和 server.root_api_key 都未配置时,Server 会自动进入 dev 模式。在该模式下,请求不需要提供有效凭证,并会被解析为默认的 ROOT/default/default 身份。该行为容易把“监听在本机”误当作认证边界;一旦服务被代理、端口被转发,或浏览器可以跨源访问本地接口,无凭证调用方就可能获得过高权限。

本次修改的核心目标是删除这条无凭证认证路径:

  • auth_mode = "dev" 不再是合法运行模式;
  • 未显式配置 auth_mode 时,Server 默认选择 api_key;
  • api_key 和 trusted 模式都要求配置 server.root_api_key;
  • 本地直连开发改为使用 trusted + root_api_key + account/user;
  • Embedded Gateway 场景继续收敛到 api_key;
  • Gateway 业务请求继续要求真实 User/Admin API Key,root key 只用于管理操作。

这是一个 breaking change。依赖旧 Dev / keyless 模式的配置需要迁移。

Human Involvement

  • A human participated in the implementation or review loop
  • This PR was generated entirely by AI agents without human participation in the loop

Related Issue

Type of Change

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update
  • Refactoring (no functional changes)
  • Performance improvement
  • Test update

Changes Made

1. 删除 Server 端 Dev 认证模式

  • 删除 openviking/server/auth/plugins/dev.py;
  • 从内置 AuthMode、认证插件注册、health check 和 Server 初始化流程中移除 Dev;
  • 删除“未配置 root key 时自动进入 Dev”的推导逻辑;
  • 未显式配置 auth_mode 时,默认使用 api_key;
  • 显式配置 auth_mode = "dev" 时启动失败,并提示使用 openviking-server init 迁移;
  • 保留第三方自定义 AuthPlugin 能力,但保留字 dev 不允许重新注册为自定义认证模式。

2. 调整本地初始化与迁移流程

openviking-server init 现在按部署方式生成显式认证配置:

  • Local:生成 trusted 模式配置,并写入 root key;
  • Remote:生成 api_key 模式配置,并要求配置 root key;
  • Embedded Gateway:最终 Server 模式使用 api_key,避免 Gateway 运行在 Trusted 模式下。

旧配置不会在更新 VLM 或 Embedding 时被静默迁移。认证配置缺失或仍使用 Dev 时,启动错误会提示运行 openviking-server init 并选择 Update server & auth。

3. 更新 CLI、Gateway、VikingBot 和 Web Studio 的认证语义

  • Rust ov config 改为先读取 /health,并在服务端需要认证时要求 API key;
  • CLI 的 root key / user key 流程按 API Key 与 Trusted 的服务端模式分别处理;
  • Gateway 移除 Dev 身份例外,不再合成匿名 default/default ROOT;
  • root key 不能作为 Gateway 业务 key;
  • VikingBot 删除 Dev localhost boundary、无 key forwarded identity 和默认 Dev principal;
  • Web Studio 删除 Dev 状态、Dev identity headers 和 Dev Gateway 权限分支。

4. 插件安装器不再生成 keyless 配置

  • 共享插件安装器不再默认写入指向 http://127.0.0.1:1933 的无 key ovcli.conf;
  • 交互安装在没有已有 key 时会持续要求输入 API Key;
  • 非交互安装缺少 key 或传入空 key 时,在写入配置前以退出码 2 失败;
  • marketplace setup wizard 同样要求 API Key,不能保存空 key;
  • 补充安装器和 setup wizard 的必填 key 回归测试。

5. 更新文档、示例和测试

  • 更新中英文认证、部署、Gateway、配置、多租户、MCP 和相关示例文档,移除主要 Dev / keyless 运行指引;
  • 更新插件 doctor、Hermes、AML、VikingBot 和 OpenClaw 等示例说明中的旧认证语义;
  • 新增测试用 fixed-identity AuthPlugin,替代测试对生产 DevAuthPlugin 的依赖;
  • 更新 Server、CLI、Gateway、VikingBot 和 Web Studio 相关测试,使测试覆盖走真实 API Key / Trusted 路径。

Current Scope Note

本 PR 曾包含一组更大的后续修复,但为避免清理工作膨胀,相关提交已通过 Revert over-scoped auth setup changes 回退。当前 PR 正文只描述远端分支 c04652a57 仍实际包含的修改。

因此,本文不再声明以下事项已经完成:

  • 完整的 Trusted marketplace setup wizard 身份收集与 live probe;
  • Rust CLI Trusted 最终配置缺少 account/user 时的完整 fail-fast 修复;
  • whitespace-only server.root_api_key 的统一 strip / fail-fast;
  • examples/ov.conf.example 固定示例 root key 的最终安全化处理;
  • 回退前那组更大范围的插件版本 bump 与对应测试结果。

这些内容如果继续处理,应作为后续更小、更聚焦的修复提交进入本 PR 或单独 PR。

Testing

  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • I have tested this on the following platforms:
    • Linux
    • macOS
    • Windows

Local verification performed during this PR

cargo test -p ov_cli config_wizard

OPENVIKING_CONFIG_FILE=/tmp/openviking-dev-removal-nonexistent.json \
.venv/bin/python -m pytest -o addopts='' \
  tests/cli/test_setup_wizard.py \
  tests/server/test_auth.py \
  tests/server/test_gateway_embedded.py \
  tests/gateway/test_management.py \
  -q --tb=short

cd web-studio
npm test -- --run \
  src/hooks/use-app-connection.test.ts \
  src/lib/connection/onboarding.test.ts \
  src/lib/studio-permissions.test.ts \
  src/routes/gateway/-lib/quick-start.test.ts \
  src/routes/gateway/-lib/use-gateway.test.tsx \
  src/routes/gateway/route.test.tsx \
  src/routes/gateway/-components/keys-dialogs.test.tsx \
  src/components/app-shell.test.tsx \
  src/components/app-shell-recovery.test.tsx
npm run build

git diff --check
.venv/bin/python -m compileall -q openviking openviking_cli openviking_gateway bot/vikingbot

历史执行结果包括:

  • Rust CLI config wizard:116 passed, 0 failed;
  • Python Server / CLI / Gateway 相关测试:274 passed, 0 failed;
  • Web Studio 相关测试:169 passed, 0 failed,production build 成功;
  • 静态检查与 Python compileall 通过。

Current CI status

回退并推送当前范围后,GitHub Actions 已重新运行。更新本文时,已观察到多项构建、文档、Hermes 和 quick local platform checks 通过;部分集成、依赖和插件检查仍以 GitHub 最新状态为准。

Checklist

  • My code follows the project's coding style
  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • Any dependent changes have been merged and published

Screenshots (if applicable)

不适用。本 PR 主要调整认证流程、配置向导和权限边界,行为由自动化测试覆盖。

Additional Notes

兼容性影响

以下旧配置将不再启动:

{
  "server": {
    "auth_mode": "dev"
  }
}

未配置 auth_mode 和 root_api_key 的旧本地配置,也需要迁移到显式认证模式。

迁移方式

本地直连开发

运行:

openviking-server init

选择 Update server & auth 和 Local 模式,生成 Trusted 配置。客户端使用同一部署 key,并显式配置 account / user。

Embedded Gateway 或共享部署

使用 api_key 模式:

  1. 配置 Server root key;
  2. 启动 Server;
  3. 运行 ov config,使用 User Management 创建或选择普通用户;
  4. 保存该用户的 User/Admin API Key;
  5. 使用普通 key 进入 Studio Gateway 并完成 Quick Setup;
  6. root key 仅用于管理,不作为 Gateway 业务 key。

保持不变的安全边界

  • API Key root 仍不能访问租户数据面;
  • root 仍不能访问 /mcp;
  • Gateway 仍不支持 Trusted;
  • OIDC、LDAP 和第三方自定义 AuthPlugin 能力保持不变;
  • 本 PR 不把通用 CORS 或 Origin 检查作为认证边界。

@sponge225
sponge225 force-pushed the sponge/remove-dev-auth-mode branch 2 times, most recently from a09e23b to cebbe3a Compare October 20, 2026 12:06
@ZaynJarvis ZaynJarvis added the kernel Core server, runtime, storage, retrieval, SDK, and CLI. label Oct 21, 2026
@sponge225
sponge225 force-pushed the sponge/remove-dev-auth-mode branch from cebbe3a to c0065dd Compare October 21, 2026 06:56
@sponge225 sponge225 changed the title fix(auth)!: remove unauthenticated dev mode refactor(auth): remove unauthenticated dev mode Oct 21, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kernel Core server, runtime, storage, retrieval, SDK, and CLI.

Projects

Status: Backlog

Development

Successfully merging this pull request may close these issues.

2 participants