Repository navigation
feat(auth): opt-in managementAuthDisabled and disableOriginCheck for local/reverse-proxy access - #3452
feat(auth): opt-in managementAuthDisabled and disableOriginCheck for local/reverse-proxy access#3452yorkane wants to merge 4 commits into
Conversation
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.
|
⏳ DRAFT
What to do
Review readiness checklist
0/4 boxes ticked. This pull request was already a draft. Its draft status will be preserved after every issue above is resolved. |
|
Important Draft PR not reviewedDraft PRs are not automatically reviewed by default.
To automatically review draft PRs, update your CodeRabbit configuration: reviews:
auto_review:
drafts: true✨ Finishing Touches 💡 1🛠️ Fix failing CI checks 💡
🧪 Generate unit tests (beta)
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. Comment |
리뷰 · 우선순위 52 / 80이 PR은 로컬 단일 사용자·외부 리버스 프록시 배포에서 대시보드와 gui/src/i18n/*.ts - 여러 로케일에서 tests/ - src/server/management-auth.ts - src/server/auth-cors.ts - src/types/config.ts - PR 상태 - draft, 메인테이너의 판단이 필요한 지점
너의 추천 이 댓글은 grok-bot이 작성했습니다 |
|
关闭:不再走上游。该功能(managementAuthDisabled / disableOriginCheck)继续在 fork 分支 codex/shadow-call-per-source-modelmap 内维护,仅服务自己的本地部署场景。 |
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.managementAuthDisabled(commit 1,233bb1ebd): whentrueand the process binds a loopback hostname,requireManagementAuthskips the admin-token check on/api/*. The flag is exposed onGET/PUT /api/settingsand rendered as a dashboard switch. Non-loopback binds are unaffected — the guard is in the auth path itself, not the listener.localhost origin accepted under auth-disabled(commit 2,e77c17642): whenmanagementAuthDisabledis on,isAllowedManagementOriginalso accepts any loopback origin (localhost/127.0.0.1/::1), not just the process-derived origin. A browser visitinghttp://localhost:10300is no longer 403-blocked while the process reportshttp://127.0.0.1:10300as its origin.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 onGET/PUT /api/settings, rendered as a second dashboard switch, and thecorsAllowOriginszod 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).
SettingsDatacarries both new fields,use-dashboard-dataaddstoggleManagementAuthandtoggleDisableOriginCheck.Tests: a new
tests/auth-config-options.test.tscovers the management-bypass flag (loopback vs. non-loopback, with and without correct token), the localhost-origin acceptance undermanagementAuthDisabled, thedisableOriginCheckshort-circuit, thecorsAllowOriginsallowlist, and the zod-schema persistence for all three fields (14 cases, 22 expect() calls, all pass).Why this is three commits, not one
disableOriginCheckis the broader kill-switch,localhost origin acceptedis the narrow fix for the loopback-onlymanagementAuthDisabledflow. They are independent: turning ondisableOriginCheckdoes not turn onmanagementAuthDisabledand vice versa.Security
false. None of them take effect without an explicit operator action through the dashboard orPUT /api/settings.managementAuthDisabledis gated insiderequireManagementAuth: the loopback checkisLoopbackHostname(config.hostname)runs before the bypass, so a misconfigured public bind cannot trigger it. Verified by the auth-config-options testnon-loopback bind + flag on still rejects (no bypass).disableOriginCheckis 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 withmanagementAuthDisabledyields fully open local access; pairing it withcorsAllowOriginsyields a narrower allowlist. The choice stays with the operator.PUT /api/settings; no new unauthenticated surface.src/server/auth-cors.ts,src/server/management-auth.ts) are listed inpr-sponsored-surface.cjsRESTRICTED_FILES, so the deterministic-hygiene gate flags this PR asunsponsored_surface. A maintainer should apply themaintainer-sponsoredlabel after security review perMAINTAINERS.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 13management route registry reconciliationchecks.bun run privacy:scan— passes.upstream/dev(0bf9d080b); conflicts with the upstreamcodexDesktopAuthlessfield are resolved by merging the new fields into the same response/struct/error-message sites (theresolveManagementAdmissionhelper is preserved alongside the newmanagementAuthDisabledshort-circuit).8597ed51arunning at127.0.0.1:10300(version2.43.0). The two new switches render on the Dashboard page;PUT /api/settingsacceptsmanagementAuthDisabledanddisableOriginCheckand reflects them back on the nextGET. Screenshot:Checklist
PUT /api/configchange is deliberately not included in this PR — that endpoint is registered asexempt: { reason: "disabled" }upstream and the GUI JSON editor already goes throughPUT /editor/api/providers(seegui/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.corsAllowOriginszod schema entry is also added so the existing field persists.falsedefault; the auth-bypass flag is guarded byisLoopbackHostname; the origin-bypass flag is labeled as a security trade-off; no new unauthenticated surface. Awaitingmaintainer-sponsoredlabel perMAINTAINERS.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.