Skip to content

feat(core): accept non-loopback HTTP origin behind OAC_ALLOW_INSECURE_ORIGIN - #3

Closed
sunyalou wants to merge 1 commit into
mainfrom
feat/core-allow-insecure-origin
Closed

sunyalou wants to merge 1 commit into
mainfrom
feat/core-allow-insecure-origin

Conversation

@sunyalou

@sunyalou sunyalou commented Oct 3, 2026

Copy link
Copy Markdown
Owner

目标

OAC-3:Core 在 OAC_ALLOW_INSECURE_ORIGIN 打开时接受非 loopback 的 http:// public origin,并正常派生 ws:// daemon URL、启动 Runtime gateway;默认关闭时行为与现状完全一致。

消费 OAC-2(#2)派生的 OAC_ALLOW_INSECURE_ORIGIN="1"(config.json 顶层 allow_insecure_origin)。

改动(仅 services/core)

  • services/core/internal/deployment/public_url.go:新增导出变体 ValidateCoreURLAllowingInsecure,与 ValidateCoreURL 共享同一私有实现;唯一差异是开启时额外接受非 loopback 的 http scheme。ValidateCoreURL 的签名与语义保持不变,共享向量不弱化。变体导出,供 OAC-4 复用同一判定。
  • services/core/cmd/server/process_configuration.go:publicURL() 读取 OAC_ALLOW_INSECURE_ORIGIN(仅 "1" 视为开启,遵循仓库派生布尔惯例如 OAC_LOG_ADD_SOURCE,不做别名/fallback),开启时选择放宽变体。默认关闭时错误信息与行为逐字节不变。
  • 测试:
    • services/core/internal/deployment/rules_test.go:ValidateCoreURLAllowingInsecure 接受非 loopback http://IP(含 IPv6),仍拒绝非法形态;并断言 ValidateCoreURL 仍拒绝非 loopback HTTP。
    • services/core/cmd/server/process_configuration_test.go:开关未设/为 "0"/"true"/"yes"/"2" 时拒绝非 loopback HTTP;开关为 "1" 时接受并原样返回,且 runtimeWebSocketURL 派生 ws://10.0.0.5:8080/api/v1/agent-daemon/ws;开关开时仍拒绝非规范 origin。
    • services/core/cmd/server/daemon_bootstrap_test.go:runtimeWebSocketURL 的 https→wss / http→ws 映射,含非 loopback 与 IPv6。

未改动 installation facts:Web 从自身 env 读取该开关(OAC-2 已写入 web env),无需扩张 Core API。未触碰 deploy/install(OAC-2 范围)与 ValidateCoreURL 契约。

验证

命令 结果
make check-runtime-contract PASS(exit 0)
make check-core services/core/internal/deployment、services/core/cmd/server 等 54 个包 ok;check-core-store 461 tests ok;两个 Python 测试 ok;仅 services/core/internal/nativeinstaller 失败(见下)
make check-names PASS
python3 scripts/ci_plan.py plan --base origin/main --head HEAD jobs: hygiene, backend, api

make check-core 的失败与本改动无关,且在本环境未改动的 origin/main(28d34ff0,clean tree)上同样复现:

  • TestBootstrapCommandDiscardsTimedOutResponse:环境 curl 7.29.0/NSS 对 --max-time 0.3 报 “expected a proper numerical parameter”。
  • TestBootstrapDownloadsVerifiedPlatformAcrossHTTPSRedirect:curl 7.29.0/NSS 拒绝 httptest 证书(Certificate type not approved for application)。

OAC_TEST_DATABASE_URL 未配置,store 集成测试按设计 skip(package ok)。

已知限制

  • 放宽仅在显式设置 OAC_ALLOW_INSECURE_ORIGIN=1 时生效,此时凭据/API key 走明文,仅面向开发/测试场景。
  • 不改动 TLS 证书校验,不引入 InsecureSkipVerify。

Refs: OAC-3;依赖 OAC-2 #2 派生的 env 名与值。

…_ORIGIN

Add an explicitly named ValidateCoreURLAllowingInsecure variant and select it
in publicURL when the installer-derived OAC_ALLOW_INSECURE_ORIGIN is "1".
ValidateCoreURL keeps its signature and default contract, so a Core without the
switch behaves exactly as before and the shared origin vectors stay unchanged.
The relaxed origin still derives ws:// through runtimeWebSocketURL, so the
Runtime gateway starts on a plain HTTP public URL.

Co-authored-by: multica-agent <github@multica.ai>

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 219bb86100

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +54 to +58
// allowInsecureOrigin reads OAC_ALLOW_INSECURE_ORIGIN, which the installer
// derives from config.json allow_insecure_origin. It is never inferred from
// OAC_PUBLIC_URL or read from another variable.
func allowInsecureOrigin() bool {
return os.Getenv("OAC_ALLOW_INSECURE_ORIGIN") == "1"

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Render the insecure-origin switch from installation settings

When this runs through the supported oac apply installer, allow_insecure_origin is rejected by config.schema.json and configuration.core_environment never emits OAC_ALLOW_INSECURE_ORIGIN; therefore a non-loopback http:// public_url still makes Core fail startup, and hand-editing generated/core.env is rejected on the next apply. Render and document the switch as a process setting so the advertised managed-installation path can actually enable it.

AGENTS.md reference: AGENTS.md:L46-L48

Useful? React with 👍 / 👎.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant