Skip to content

feat(auth): opt-in managementAuthDisabled and disableOriginCheck for local/reverse-proxy access - #3452

Closed
yorkane wants to merge 4 commits into
lidge-jun:devfrom
yorkane:pr/auth-config-options
Closed

yorkane wants to merge 4 commits into
lidge-jun:devfrom
yorkane:pr/auth-config-options

Conversation

@yorkane

@yorkane yorkane commented Sep 4, 2026 •

Copy link
Copy Markdown

Summary

Three opt-in switches for local-access and external-reverse-proxy deployments of opencodex. All default to false; each is a separate commit so it can be reviewed and reverted independently.

  1. managementAuthDisabled (commit 1, 233bb1ebd): when true and the process binds a loopback hostname, requireManagementAuth skips the admin-token check on /api/*. The flag is exposed on GET/PUT /api/settings and rendered as a dashboard switch. Non-loopback binds are unaffected — the guard is in the auth path itself, not the listener.
  2. localhost origin accepted under auth-disabled (commit 2, e77c17642): when managementAuthDisabled is on, isAllowedManagementOrigin also accepts any loopback origin (localhost / 127.0.0.1 / ::1), not just the process-derived origin. A browser visiting http://localhost:10300 is no longer 403-blocked while the process reports http://127.0.0.1:10300 as its origin.
  3. disableOriginCheck (commit 3, 8955ab66f): an explicit opt-in to bypass all origin/CORS gates on both the data plane and the management API, so an external reverse proxy (e.g. https://10101-235.ai-t.wtvdev.com) can reach the dashboard and API without cross-origin blocks. The flag is exposed on GET/PUT /api/settings, rendered as a second dashboard switch, and the corsAllowOrigins zod schema entry is also added so the field persists.

GUI: two new switch panels on the Dashboard page, each with a localized title and hint (en, fr, ja, ko, ru, tr, zh, zh-TW, de). SettingsData carries both new fields, use-dashboard-data adds toggleManagementAuth and toggleDisableOriginCheck.

Tests: a new tests/auth-config-options.test.ts covers the management-bypass flag (loopback vs. non-loopback, with and without correct token), the localhost-origin acceptance under managementAuthDisabled, the disableOriginCheck short-circuit, the corsAllowOrigins allowlist, and the zod-schema persistence for all three fields (14 cases, 22 expect() calls, all pass).

Why this is three commits, not one

  • Each flag changes a different gate (auth bypass vs. origin acceptance vs. global origin disable). The motivation, the failure mode it fixes, and the blast radius are all different; bundling them would obscure both the review and the rollback story.
  • The two origin-related flags are layered intentionally: disableOriginCheck is the broader kill-switch, localhost origin accepted is the narrow fix for the loopback-only managementAuthDisabled flow. They are independent: turning on disableOriginCheck does not turn on managementAuthDisabled and vice versa.

Security

  • Every flag defaults to false. None of them take effect without an explicit operator action through the dashboard or PUT /api/settings.
  • managementAuthDisabled is gated inside requireManagementAuth: the loopback check isLoopbackHostname(config.hostname) runs before the bypass, so a misconfigured public bind cannot trigger it. Verified by the auth-config-options test non-loopback bind + flag on still rejects (no bypass).
  • disableOriginCheck is a security trade-off and the description is honest about it: "Disable all origin/CORS checks so an external reverse proxy can reach the dashboard and API. Use with care." Pairing it with managementAuthDisabled yields fully open local access; pairing it with corsAllowOrigins yields a narrower allowlist. The choice stays with the operator.
  • The flags are exposed through the existing admin-token-protected PUT /api/settings; no new unauthenticated surface.
  • Touched files in the security boundary (src/server/auth-cors.ts, src/server/management-auth.ts) are listed in pr-sponsored-surface.cjs RESTRICTED_FILES, so the deterministic-hygiene gate flags this PR as unsponsored_surface. A maintainer should apply the maintainer-sponsored label after security review per MAINTAINERS.md; the description above is the review context.

Verification

  • bun run typecheck (Bun 1.4.0) — clean.
  • bun test tests/server-management-auth.test.ts tests/cli-management-auth.test.ts tests/server-auth.test.ts tests/management-route-registry.test.ts tests/management-origin-tls.test.ts tests/auth-config-options.test.ts — 180 pass / 0 fail, including the 13 management route registry reconciliation checks.
  • bun run privacy:scan — passes.
  • Rebased onto upstream/dev (0bf9d080b); conflicts with the upstream codexDesktopAuthless field are resolved by merging the new fields into the same response/struct/error-message sites (the resolveManagementAdmission helper is preserved alongside the new managementAuthDisabled short-circuit).
  • Manual GUI check on a build of 8597ed51a running at 127.0.0.1:10300 (version 2.43.0). The two new switches render on the Dashboard page; PUT /api/settings accepts managementAuthDisabled and disableOriginCheck and reflects them back on the next GET. Screenshot:

Dashboard with managementAuthDisabled and disableOriginCheck switches

Checklist

  • Scope stays focused and avoids unrelated cleanup. The PUT /api/config change is deliberately not included in this PR — that endpoint is registered as exempt: { reason: "disabled" } upstream and the GUI JSON editor already goes through PUT /editor/api/providers (see gui/tests/use-json-config-editor.test.tsx:149), so re-enabling the old surface has no current consumer and would erode an existing gate for no win. It can be revisited as a separate proposal if a real user need surfaces.
  • Docs or release notes were updated when needed. i18n keys added in en/fr/ja/ko/ru/tr/zh/zh-TW/de. The corsAllowOrigins zod schema entry is also added so the existing field persists.
  • Security-sensitive changes were reviewed for secrets, auth, and unsafe defaults: every flag is opt-in with false default; the auth-bypass flag is guarded by isLoopbackHostname; the origin-bypass flag is labeled as a security trade-off; no new unauthenticated surface. Awaiting maintainer-sponsored label per MAINTAINERS.md.

Review readiness checklist

This PR stays in draft until every box below is ticked. Tick all four boxes once the requirements are met:

  • All CI tests are green on my local testing.

  • I pushed my PR to the latest dev commit.

  • I resolved all correct Codex and CodeRabbit findings.

  • My PR is ready for review.

Add a managementAuthDisabled config flag (loopback binds only) that
bypasses admin-token auth on /api/*, so the dashboard and management API
are directly accessible without credentials in a local single-user
deployment.

Changes:
- src/types/config.ts + src/config.ts: new optional boolean
  managementAuthDisabled (defaults false).
- src/server/management-auth.ts: requireManagementAuth returns null
  immediately when the flag is on and the bind is loopback.
- src/server/management/config-routes.ts: GET/PUT /api/settings
  expose the flag alongside the other settings.
- GUI: SettingsData carries the field; use-dashboard-data adds a
  toggleManagementAuth; dashboard-overview renders a switch panel;
  i18n keys added (en + zh canonical, others as English placeholders).

The flag is guarded to loopback hostname so it can never take effect on a
public listener. 10100 instance remains token-gated.
When managementAuthDisabled is on (loopback only), the management API
origin gate still required an exact match against the process-derived
origin (http://127.0.0.1:PORT). A browser visiting http://localhost:PORT
sends Origin: http://localhost:PORT, which did not match, so every async
dashboard request returned 403 "cross-origin request blocked" even though
auth was disabled.

Relax the origin check under managementAuthDisabled to accept any
loopback origin (localhost/127.0.0.1/::1), not just the exact process
origin. Non-loopback binds are unaffected by the guard.
Add a disableOriginCheck config flag that bypasses all origin/CORS
gates on both the data plane and management API, so an external reverse
proxy (e.g. https://10101-235.ai-t.wtvdev.com) can reach the dashboard and
API without 403 cross-origin blocks.

When enabled, isAllowedRequestOrigin and isAllowedManagementOrigin return
true immediately, accepting any Origin header. Also adds corsAllowOrigins
to the zod schema (it existed only in the type before) so it persists.

Exposes the flag on GET/PUT /api/settings and adds a dashboard toggle
alongside the management-auth switch. i18n keys added for all locales.

This is a security trade-off: only enable when you understand the proxy
is reachable by arbitrary origins. Pair with managementAuthDisabled for
fully open local access, or keep auth on and use corsAllowOrigins for a
narrower allowlist.
@github-actions github-actions Bot added the intake: hygiene-blocked Deterministic PR hygiene checks failed label Sep 4, 2026
@github-actions

github-actions Bot commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

⚠️ Deterministic hygiene checks failed.

  • missing_regression_test — Behavior changed under src/ or gui/src/ without a test change. Add focused coverage or obtain test-exception-approved.
  • unsponsored_surface — This changes an authentication, workflow, release-automation, or dependency surface. MAINTAINERS.md requires security review for these; ask a maintainer to apply maintainer-sponsored once they have reviewed it. Paths: src/server/auth-cors.ts, src/server/management-auth.ts.

@github-actions github-actions Bot added the enhancement New feature or request label Sep 4, 2026
@github-actions

github-actions Bot commented Sep 4, 2026 •

Copy link
Copy Markdown
Contributor

⏳ DRAFT

  • hygiene: unsponsored_surface.

What to do

  • Fix unsponsored_surface — This changes an authentication, workflow, release-automation, or dependency surface. MAINTAINERS.md requires security review for these; ask a maintainer to apply maintainer-sponsored once they have reviewed it. Paths: src/server/auth-cors.ts, src/server/management-auth.ts.
  • Tick all four boxes in the PR description once you're done (currently 0/4).

Review readiness checklist

  • ⬜ All CI tests are green on my local testing.
  • ⬜ I pushed my PR to the latest dev commit.
  • ⬜ I resolved all correct Codex and CodeRabbit findings.
  • ⬜ My PR is ready for review.

0/4 boxes ticked.

This pull request was already a draft. Its draft status will be preserved after every issue above is resolved.
@yorkane Tick the boxes once your local CI is green, your branch is on the latest dev commit, and every correct Codex and CodeRabbit finding is resolved.

@github-actions
github-actions Bot marked this pull request as draft September 4, 2026 09:42
@coderabbitai

coderabbitai Bot commented Sep 4, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

Important

Draft PR not reviewed

Draft PRs are not automatically reviewed by default.

  • Trigger a manual review

To automatically review draft PRs, update your CodeRabbit configuration:

reviews:
  auto_review:
    drafts: true
✨ Finishing Touches 💡 1
🛠️ Fix failing CI checks 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@lidge-jun

Copy link
Copy Markdown
Owner

리뷰 · 우선순위 52 / 80

이 PR은 로컬 단일 사용자·외부 리버스 프록시 배포에서 대시보드와 /api/*가 막히는 문제를 풀려고, 기본값 false인 설정 스위치 두 개와 그 사이의 좁은 보완을 세 커밋으로 나눕니다. 현재 dev HEAD 52f4ffa5d(#3394 OpenCode Go Grok 4.6 Responses)에는 아직 이 필드가 없고, 관리면·CORS 쪽 기존 축은 src/server/management-auth.ts의 requireManagementAuth / resolveManagementAdmission, src/server/auth-cors.ts의 isAllowedManagementOrigin / isAllowedRequestOrigin / corsAllowOrigins, 그리고 이미 머지된 codexDesktopAuthless(#3207) 같은 옵트인 패턴입니다. 커밋 1은 managementAuthDisabled를 켜면 isLoopbackHostname(config.hostname)일 때만 admin 토큰 검사를 건너뛰게 하고, GET/PUT /api/settings와 대시보드 스위치로 노출합니다. 커밋 2는 그 플래그가 켜진 루프백에서 Origin: http://localhost:PORT와 프로세스 기준 http://127.0.0.1:PORT가 어긋나 403 나던 관리면 origin 게이트를, 루프백 Origin이면 받아들이도록 완화합니다. 커밋 3은 disableOriginCheck로 데이터면·관리면 origin/CORS를 전부 통과시키고, 타입에만 있던 corsAllowOrigins를 zod에도 넣어 저장되게 합니다. GUI는 DashboardSidecarPanels 옆에 스위치 두 개와 i18n 키를 추가합니다. 로컬에서 admin 토큰·localhost/127.0.0.1 불일치·프록시 Origin 403은 실제로 자주 부딪히는 축이고, 기본값 off + 루프백 가드 + 기존 corsAllowOrigins와 겹치지 않게 레이어를 나눈 설명은 분명합니다. 다만 지금 dev 기준으로는 인증·admission 제한 표면(auth-cors.ts, management-auth.ts)을 건드리는 기여라 hygiene이 unsponsored_surface로 draft/차단 상태이고, src/·gui/src/ 변경인데 회귀 테스트 추가가 없어 missing_regression_test도 같이 걸려 있습니다. 리버스 프록시만의 목적이면 이미 HEAD에 있는 corsAllowOrigins(그리고 tests/management-origin-tls.test.ts가 증명하는 https Origin 허용)가 더 좁은 해법이고, disableOriginCheck는 그 위에 올라가는 전역 킬 스위치라 메인테이너가 “문서화된 좁은 경로로 충분한지 / 핵옵션을 제품 스위치로 둘지”를 먼저 정해야 합니다.

gui/src/i18n/*.ts - 여러 로케일에서 dash.disableOriginCheckHint 값 뒤에 줄바꿈 없이 dash.searchModel 또는 dash.searchModelHint가 같은 줄에 붙어 있습니다. JS 문법은 통과할 수 있어도 리뷰·머지 충돌·포맷 게이트에 바로 걸리는 지저분한 diff입니다. en/ko/de/fr 등 공통으로 고치고, zh만 번역된 상태이니 나머지 로케일도 최소 줄 단위는 맞춰 주세요.

tests/ - managementAuthDisabled 루프백 바이패스, 비루프백에서 무시, disableOriginCheck가 isAllowedRequestOrigin/isAllowedManagementOrigin를 통과시키는 경우, 그리고 settings GET/PUT round-trip에 대한 집중 테스트가 없습니다. hygiene도 missing_regression_test로 이미 실패합니다. tests/settings-stream-mode.test.ts의 codexDesktopAuthless 패턴이나 tests/management-origin-tls.test.ts / tests/server-management-auth.test.ts에 맞춰 추가하는 편이 맞습니다.

src/server/management-auth.ts - managementAuthDisabled 가드는 config.hostname만 봅니다. HEAD 주석대로 공개 바인드와 루프백 리스너가 한 프로세스를 공유할 때 requestPolicyView는 bind hostname을 바꾸지만, 이 바이패스는 공유 config hostname을 봅니다. 0.0.0.0 공개 바인드에서는 의도대로 안 켜지지만, “루프백 리스너만 열고 싶다”는 이중 리스너 시나리오와 문서/구현이 같은지 한 줄로 확인해 주세요.

src/server/auth-cors.ts - disableOriginCheck는 루프백 가드가 없습니다. 대시보드에서 켠 뒤 hostname을 공개로 바꾸면 origin 검사가 전부 열립니다. PR 본문도 인정하지만, 제품 스위치로 둘지 corsAllowOrigins 문서화·GUI만으로 둘지 메인테이너 판단이 필요합니다.

src/types/config.ts - managementAuthDisabled 주석의 “non-loopback이면 data-plane credential이 필요하다”는 표현이 이 플래그 자체 동작과 어긋날 수 있습니다. 플래그는 관리면 토큰만 건드리고, 데이터면은 기존 isApiAuthRequired(config.hostname)를 따릅니다. 주석을 관리면 범위로 좁혀 주세요.

PR 상태 - draft, intake: hygiene-blocked, hygiene/enforce-target 실패 사유가 unsponsored_surface(경로: src/server/auth-cors.ts, src/server/management-auth.ts)와 missing_regression_test입니다. 체크리스트 0/4이고 base는 옛 0bf9d080b 근처라 최신 dev(52f4ffa5d)에 다시 맞출 필요가 있습니다.

메인테이너의 판단이 필요한 지점

  • auth-cors.ts / management-auth.ts 변경을 maintainer-sponsored로 보안 검토·라벨할지
  • 리버스 프록시 요구를 corsAllowOrigins만으로 받을지, disableOriginCheck 핵옵션을 공식 스위치로 둘지
  • managementAuthDisabled를 로컬 UX로 받을지, 아니면 admin 토큰 UX/문서 개선만으로 충분할지
  • GUI 대시보드에 보안 스위치를 두는 위치·카피가 적절한지(사이드카 패널 옆)

너의 추천
지금은 머지하지 마세요. 기여자에게 i18n 줄바꿈 정리 + managementAuthDisabled/disableOriginCheck//api/settings 회귀 테스트 추가 + 최신 dev 리베이스를 요청하고, 메인테이너가 보안 검토 후 maintainer-sponsored를 붙일지 결정하세요. 프록시만의 목적이면 corsAllowOrigins 경로를 먼저 안내하고 disableOriginCheck는 축소·보류하는 편이 안전합니다.

이 댓글은 grok-bot이 작성했습니다

@yorkane

yorkane commented Sep 6, 2026

Copy link
Copy Markdown
Author

关闭:不再走上游。该功能(managementAuthDisabled / disableOriginCheck)继续在 fork 分支 codex/shadow-call-per-source-modelmap 内维护,仅服务自己的本地部署场景。

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

Labels

enhancement New feature or request intake: hygiene-blocked Deterministic PR hygiene checks failed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants