Skip to content

Commit 5ed3dcd

Browse files
committed
docs: document OPENCODEX_API_AUTH_TOKEN and config recovery behavior
README (EN/KO): add "Remote access" subsection explaining non-loopback token requirement, and note that invalid config.json is backed up before fallback. docs-site configuration reference (EN/KO): add hostname field to config table, dedicated "Remote access" section with usage examples and security caution, update opening paragraph to describe backup + warning behavior. Closes #25, closes #24.
1 parent 03d6bde commit 5ed3dcd

4 files changed

Lines changed: 113 additions & 6 deletions

File tree

README.ko.md

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,11 @@ npm uninstall -g @bitkyc08/opencodex # 또는: bun remove -g @bitkyc08/opencod
171171

172172
## 설정
173173

174-
설정 파일은 `~/.opencodex/config.json`에 저장됩니다. 최소 설정 예시:
174+
설정 파일은 `~/.opencodex/config.json`에 저장됩니다. 파일이 깨진 경우(잘못된 JSON 등)
175+
opencodex는 `config.json.invalid-<timestamp>`로 백업하고 경고를 출력한 뒤 기본값으로 시작합니다.
176+
원본 파일이 조용히 사라지는 일은 없습니다.
177+
178+
최소 설정 예시:
175179

176180
```json
177181
{
@@ -209,6 +213,25 @@ npm uninstall -g @bitkyc08/opencodex # 또는: bun remove -g @bitkyc08/opencod
209213

210214
WebSocket 전송은 기본적으로 꺼져 있습니다. Codex가 HTTP/SSE 대신 Responses WebSocket 경로를 사용하게 하려면 `"websockets": true`를 설정하세요.
211215

216+
### 원격 접근
217+
218+
기본적으로 opencodex는 `127.0.0.1`(루프백)에 바인딩되며 별도 인증이 필요 없습니다.
219+
`"hostname": "0.0.0.0"`으로 LAN에 노출할 경우, opencodex는 관리 API(`/api/*`)와 데이터 플레인(`/v1/responses`) 모두에 bearer 토큰을 요구합니다:
220+
221+
```bash
222+
export OPENCODEX_API_AUTH_TOKEN="your-secret-token"
223+
ocx start
224+
```
225+
226+
비루프백 바인딩 시 이 환경 변수가 없으면 프록시 시작이 거부됩니다.
227+
클라이언트(스크립트, 원격 머신)는 모든 요청에 토큰을 포함해야 합니다:
228+
229+
```
230+
x-opencodex-api-key: your-secret-token
231+
```
232+
233+
토큰은 타이밍 공격 방지를 위해 상수 시간으로 비교됩니다.
234+
212235
모든 필드에 대한 자세한 내용은 **[설정 레퍼런스](https://lidge-jun.github.io/opencodex/ko/reference/configuration/)** 를 참고하세요.
213236

214237
## 문서

README.md

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,11 @@ native Codex config/catalog/history, and deletes `~/.opencodex`.
232232

233233
## Configuration
234234

235-
Config lives at `~/.opencodex/config.json`. Here's a typical multi-provider setup:
235+
Config lives at `~/.opencodex/config.json`. If the file cannot be parsed (e.g. truncated or
236+
manually broken JSON), opencodex backs it up to `config.json.invalid-<timestamp>`, prints a warning,
237+
and falls back to defaults — so your original file is never silently lost.
238+
239+
Here's a typical multi-provider setup:
236240

237241
```json
238242
{
@@ -288,6 +292,26 @@ Local models work too. Point opencodex at any OpenAI-compatible server running o
288292

289293
WebSocket transport is off by default. Set `"websockets": true` only if you want Codex to advertise and use the Responses WebSocket path instead of HTTP/SSE.
290294

295+
### Remote access
296+
297+
By default opencodex binds to `127.0.0.1` (loopback) and requires no extra authentication.
298+
If you set `"hostname": "0.0.0.0"` to expose the proxy on the LAN, opencodex requires a bearer token
299+
to protect both the management API (`/api/*`) and the data-plane (`/v1/responses`):
300+
301+
```bash
302+
export OPENCODEX_API_AUTH_TOKEN="your-secret-token"
303+
ocx start
304+
```
305+
306+
The proxy refuses to start without this variable when binding beyond loopback.
307+
Clients (scripts, remote machines) must include the token in every request:
308+
309+
```
310+
x-opencodex-api-key: your-secret-token
311+
```
312+
313+
The token is compared in constant time to prevent timing attacks.
314+
291315
opencodex leaves existing Codex resume history untouched by default. This avoids changing Codex's
292316
local thread index just because the proxy started, but Codex App may hide old OpenAI-backed project
293317
threads and opencodex-created `exec` threads while `opencodex` is the active provider. If you want

docs-site/src/content/docs/ko/reference/configuration.md

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,17 @@ description: ~/.opencodex/config.json의 모든 필드 — 최상위 옵션, 프
44
---
55

66
opencodex는 `~/.opencodex/config.json`으로 설정됩니다. 이 파일은 `ocx init`과 대시보드가
7-
작성하지만, 직접 편집할 수도 있습니다. 프록시는 시작 시 이 파일을 다시 읽습니다. 파일이 없거나
8-
유효하지 않으면 기본값(단일 `openai` 포워드 프로바이더)으로 폴백합니다.
7+
작성하지만, 직접 편집할 수도 있습니다. 프록시는 시작 시 이 파일을 다시 읽습니다. 파일을 파싱할 수
8+
없는 경우(잘못된 JSON 등) opencodex는 `config.json.invalid-<timestamp>`로 백업하고 콘솔에 경고를
9+
출력한 뒤 기본값으로 시작합니다. 파일이 아예 없으면 기본값(단일 `openai` 포워드 프로바이더)으로
10+
폴백합니다.
911

1012
## 최상위 (`OcxConfig`)
1113

1214
| Field | Type | Default | Meaning |
1315
| --- | --- | --- | --- |
1416
| `port` | `number` | `10100` | 프록시가 수신 대기하는 포트. |
17+
| `hostname?` | `string` | `"127.0.0.1"` | 바인드 주소. LAN에 노출하려면 `"0.0.0.0"` 설정 (`OPENCODEX_API_AUTH_TOKEN` 필수; 아래 [원격 접근](#원격-접근) 참조). |
1518
| `providers` | `Record<string, OcxProviderConfig>` || 프로바이더 이름 → 설정 맵. |
1619
| `defaultProvider` | `string` | `"openai"` | 라우팅에서 더 나은 매치를 찾지 못했을 때 사용하는 프로바이더. |
1720
| `subagentModels?` | `string[]` || Codex의 서브에이전트 선택기에서 가장 먼저 노출되는 최대 5개의 `provider/model` id. |
@@ -36,6 +39,33 @@ store에 따로 저장됩니다. 기존 thread id는 계정 affinity를 유지
3639
health를 기준으로 자동 라우팅할 수 있습니다.
3740
:::
3841

42+
## 원격 접근
43+
44+
기본적으로 opencodex는 `127.0.0.1`(루프백 전용)에 바인딩됩니다. `hostname``0.0.0.0` 같은
45+
비루프백 주소로 설정하면, opencodex는 관리 API(`/api/*`)와 데이터 플레인(`/v1/responses`) **모두**
46+
토큰 인증을 강제합니다.
47+
48+
시작 전에 `OPENCODEX_API_AUTH_TOKEN` 환경 변수를 설정하세요:
49+
50+
```bash
51+
export OPENCODEX_API_AUTH_TOKEN="your-secret-token"
52+
ocx start
53+
```
54+
55+
비루프백 바인딩 시 이 변수가 없으면 프록시 시작이 거부됩니다. 클라이언트는 모든 요청에
56+
`x-opencodex-api-key` 헤더로 토큰을 포함해야 합니다:
57+
58+
```
59+
x-opencodex-api-key: your-secret-token
60+
```
61+
62+
토큰은 타이밍 사이드 채널 방지를 위해 상수 시간(`timingSafeEqual`)으로 비교됩니다.
63+
64+
:::caution[LAN 노출]
65+
`0.0.0.0`으로 바인딩하면 프록시와 설정된 모든 프로바이더 인증 정보가 로컬 네트워크에 노출됩니다.
66+
신뢰할 수 있는 네트워크에서만 사용하고, 항상 강력한 `OPENCODEX_API_AUTH_TOKEN`을 설정하세요.
67+
:::
68+
3969
## 프로바이더 (`OcxProviderConfig`)
4070

4171
| Field | Type | Meaning |

docs-site/src/content/docs/reference/configuration.md

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,17 @@ description: Every field in ~/.opencodex/config.json — top-level options, prov
44
---
55

66
opencodex is configured by `~/.opencodex/config.json`. It's written by `ocx init` and the dashboard,
7-
but you can edit it directly; the proxy reloads it on start. Missing or invalid files fall back to a
8-
default (a single `openai` forward provider).
7+
but you can edit it directly; the proxy reloads it on start. If the file cannot be parsed (e.g.
8+
truncated or invalid JSON), opencodex backs it up to `config.json.invalid-<timestamp>`, prints a
9+
console warning, and starts with defaults. Missing files also fall back to a default (a single
10+
`openai` forward provider).
911

1012
## Top level (`OcxConfig`)
1113

1214
| Field | Type | Default | Meaning |
1315
| --- | --- | --- | --- |
1416
| `port` | `number` | `10100` | Port the proxy listens on. |
17+
| `hostname?` | `string` | `"127.0.0.1"` | Bind address. Set `"0.0.0.0"` to expose on the LAN (requires `OPENCODEX_API_AUTH_TOKEN`; see [Remote access](#remote-access) below). |
1518
| `providers` | `Record<string, OcxProviderConfig>` || Map of provider name → config. |
1619
| `defaultProvider` | `string` | `"openai"` | Provider used when routing finds no better match. |
1720
| `subagentModels?` | `string[]` || Up to 5 `provider/model` ids featured first in Codex's subagent picker. |
@@ -36,6 +39,33 @@ credential store. Existing thread ids keep account affinity, while new sessions
3639
on quota, cooldown, and health.
3740
:::
3841

42+
## Remote access
43+
44+
By default opencodex binds to `127.0.0.1` (loopback only). When `hostname` is set to a non-loopback
45+
address such as `0.0.0.0`, opencodex enforces token authentication on **both** the management API
46+
(`/api/*`) and the data-plane (`/v1/responses`).
47+
48+
Set the `OPENCODEX_API_AUTH_TOKEN` environment variable before starting:
49+
50+
```bash
51+
export OPENCODEX_API_AUTH_TOKEN="your-secret-token"
52+
ocx start
53+
```
54+
55+
The proxy refuses to start without this variable when binding beyond loopback. Clients must include
56+
the token in every request via the `x-opencodex-api-key` header:
57+
58+
```
59+
x-opencodex-api-key: your-secret-token
60+
```
61+
62+
The token is compared in constant time (`timingSafeEqual`) to prevent timing side-channels.
63+
64+
:::caution[LAN exposure]
65+
Binding to `0.0.0.0` exposes your proxy — and all configured provider credentials — to the local
66+
network. Only do this on trusted networks, and always set a strong `OPENCODEX_API_AUTH_TOKEN`.
67+
:::
68+
3969
## Providers (`OcxProviderConfig`)
4070

4171
| Field | Type | Meaning |

0 commit comments

Comments
 (0)