codex-api-proxy 0.1.3__tar.gz → 0.1.4__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (25) hide show
  1. {codex_api_proxy-0.1.3 → codex_api_proxy-0.1.4}/PKG-INFO +16 -1
  2. {codex_api_proxy-0.1.3 → codex_api_proxy-0.1.4}/README.md +15 -0
  3. {codex_api_proxy-0.1.3 → codex_api_proxy-0.1.4}/pyproject.toml +1 -1
  4. {codex_api_proxy-0.1.3 → codex_api_proxy-0.1.4}/src/codex_api_proxy/__init__.py +1 -1
  5. {codex_api_proxy-0.1.3 → codex_api_proxy-0.1.4}/src/codex_api_proxy/config.py +9 -0
  6. {codex_api_proxy-0.1.3 → codex_api_proxy-0.1.4}/src/codex_api_proxy.egg-info/PKG-INFO +16 -1
  7. {codex_api_proxy-0.1.3 → codex_api_proxy-0.1.4}/tests/test_config.py +50 -0
  8. {codex_api_proxy-0.1.3 → codex_api_proxy-0.1.4}/setup.cfg +0 -0
  9. {codex_api_proxy-0.1.3 → codex_api_proxy-0.1.4}/src/codex_api_proxy/auth.py +0 -0
  10. {codex_api_proxy-0.1.3 → codex_api_proxy-0.1.4}/src/codex_api_proxy/chat_completions.py +0 -0
  11. {codex_api_proxy-0.1.3 → codex_api_proxy-0.1.4}/src/codex_api_proxy/cli.py +0 -0
  12. {codex_api_proxy-0.1.3 → codex_api_proxy-0.1.4}/src/codex_api_proxy/main.py +0 -0
  13. {codex_api_proxy-0.1.3 → codex_api_proxy-0.1.4}/src/codex_api_proxy/models.py +0 -0
  14. {codex_api_proxy-0.1.3 → codex_api_proxy-0.1.4}/src/codex_api_proxy/sse_utils.py +0 -0
  15. {codex_api_proxy-0.1.3 → codex_api_proxy-0.1.4}/src/codex_api_proxy.egg-info/SOURCES.txt +0 -0
  16. {codex_api_proxy-0.1.3 → codex_api_proxy-0.1.4}/src/codex_api_proxy.egg-info/dependency_links.txt +0 -0
  17. {codex_api_proxy-0.1.3 → codex_api_proxy-0.1.4}/src/codex_api_proxy.egg-info/entry_points.txt +0 -0
  18. {codex_api_proxy-0.1.3 → codex_api_proxy-0.1.4}/src/codex_api_proxy.egg-info/requires.txt +0 -0
  19. {codex_api_proxy-0.1.3 → codex_api_proxy-0.1.4}/src/codex_api_proxy.egg-info/top_level.txt +0 -0
  20. {codex_api_proxy-0.1.3 → codex_api_proxy-0.1.4}/tests/test_api.py +0 -0
  21. {codex_api_proxy-0.1.3 → codex_api_proxy-0.1.4}/tests/test_auth.py +0 -0
  22. {codex_api_proxy-0.1.3 → codex_api_proxy-0.1.4}/tests/test_chat_completions.py +0 -0
  23. {codex_api_proxy-0.1.3 → codex_api_proxy-0.1.4}/tests/test_cli.py +0 -0
  24. {codex_api_proxy-0.1.3 → codex_api_proxy-0.1.4}/tests/test_models.py +0 -0
  25. {codex_api_proxy-0.1.3 → codex_api_proxy-0.1.4}/tests/test_release_version.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: codex-api-proxy
3
- Version: 0.1.3
3
+ Version: 0.1.4
4
4
  Summary: Local OpenAI-compatible HTTP proxy backed by Codex/OpenAI credentials
5
5
  Author: codex-api-proxy contributors
6
6
  License-Expression: MIT
@@ -102,6 +102,20 @@ You can also set the upstream proxy explicitly at startup:
102
102
  codex-api-proxy start --proxy=http://127.0.0.1:8118
103
103
  ```
104
104
 
105
+ If the upstream connection passes through a corporate TLS proxy or another endpoint
106
+ using a private/self-signed certificate chain, point the proxy at a CA bundle that
107
+ trusts that chain:
108
+
109
+ - `CODEX_API_PROXY_CA_BUNDLE`
110
+ - `REQUESTS_CA_BUNDLE`
111
+ - `SSL_CERT_FILE`
112
+
113
+ For example:
114
+
115
+ ```bash
116
+ CODEX_API_PROXY_CA_BUNDLE=/path/to/internal-ca-bundle.pem codex-api-proxy start
117
+ ```
118
+
105
119
  ## Run
106
120
 
107
121
  Start in the background:
@@ -164,6 +178,7 @@ Environment variables for the local server:
164
178
  - `CODEX_PROXY_PORT`
165
179
  - `CODEX_PROXY_API_KEY`
166
180
  - `CODEX_API_PROXY_HTTPS_PROXY`
181
+ - `CODEX_API_PROXY_CA_BUNDLE`
167
182
  - `CODEX_PROXY_LOG_LEVEL`
168
183
 
169
184
  Token refresh compatibility variables:
@@ -78,6 +78,20 @@ You can also set the upstream proxy explicitly at startup:
78
78
  codex-api-proxy start --proxy=http://127.0.0.1:8118
79
79
  ```
80
80
 
81
+ If the upstream connection passes through a corporate TLS proxy or another endpoint
82
+ using a private/self-signed certificate chain, point the proxy at a CA bundle that
83
+ trusts that chain:
84
+
85
+ - `CODEX_API_PROXY_CA_BUNDLE`
86
+ - `REQUESTS_CA_BUNDLE`
87
+ - `SSL_CERT_FILE`
88
+
89
+ For example:
90
+
91
+ ```bash
92
+ CODEX_API_PROXY_CA_BUNDLE=/path/to/internal-ca-bundle.pem codex-api-proxy start
93
+ ```
94
+
81
95
  ## Run
82
96
 
83
97
  Start in the background:
@@ -140,6 +154,7 @@ Environment variables for the local server:
140
154
  - `CODEX_PROXY_PORT`
141
155
  - `CODEX_PROXY_API_KEY`
142
156
  - `CODEX_API_PROXY_HTTPS_PROXY`
157
+ - `CODEX_API_PROXY_CA_BUNDLE`
143
158
  - `CODEX_PROXY_LOG_LEVEL`
144
159
 
145
160
  Token refresh compatibility variables:
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "codex-api-proxy"
3
- version = "0.1.3"
3
+ version = "0.1.4"
4
4
  description = "Local OpenAI-compatible HTTP proxy backed by Codex/OpenAI credentials"
5
5
  readme = "README.md"
6
6
  requires-python = ">=3.11"
@@ -1,3 +1,3 @@
1
1
  """OpenAI-compatible HTTP proxy backed by Codex/OpenAI credentials."""
2
2
 
3
- __version__ = "0.1.3"
3
+ __version__ = "0.1.4"
@@ -76,6 +76,14 @@ def upstream_https_proxy(explicit_proxy: str | None = None) -> str | None:
76
76
  return DEFAULT_HTTPS_PROXY
77
77
 
78
78
 
79
+ def upstream_ssl_verify() -> bool | str:
80
+ for key in ("CODEX_API_PROXY_CA_BUNDLE", "REQUESTS_CA_BUNDLE", "SSL_CERT_FILE"):
81
+ value = os.environ.get(key, "").strip()
82
+ if value:
83
+ return value
84
+ return True
85
+
86
+
79
87
  def upstream_originator() -> str:
80
88
  override = os.environ.get("CODEX_INTERNAL_ORIGINATOR_OVERRIDE", "").strip()
81
89
  return override or DEFAULT_ORIGINATOR
@@ -95,6 +103,7 @@ def upstream_client(explicit_proxy: str | None = None) -> httpx.AsyncClient:
95
103
  return httpx.AsyncClient(
96
104
  timeout=DEFAULT_TIMEOUT,
97
105
  proxy=upstream_https_proxy(explicit_proxy),
106
+ verify=upstream_ssl_verify(),
98
107
  trust_env=False,
99
108
  )
100
109
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: codex-api-proxy
3
- Version: 0.1.3
3
+ Version: 0.1.4
4
4
  Summary: Local OpenAI-compatible HTTP proxy backed by Codex/OpenAI credentials
5
5
  Author: codex-api-proxy contributors
6
6
  License-Expression: MIT
@@ -102,6 +102,20 @@ You can also set the upstream proxy explicitly at startup:
102
102
  codex-api-proxy start --proxy=http://127.0.0.1:8118
103
103
  ```
104
104
 
105
+ If the upstream connection passes through a corporate TLS proxy or another endpoint
106
+ using a private/self-signed certificate chain, point the proxy at a CA bundle that
107
+ trusts that chain:
108
+
109
+ - `CODEX_API_PROXY_CA_BUNDLE`
110
+ - `REQUESTS_CA_BUNDLE`
111
+ - `SSL_CERT_FILE`
112
+
113
+ For example:
114
+
115
+ ```bash
116
+ CODEX_API_PROXY_CA_BUNDLE=/path/to/internal-ca-bundle.pem codex-api-proxy start
117
+ ```
118
+
105
119
  ## Run
106
120
 
107
121
  Start in the background:
@@ -164,6 +178,7 @@ Environment variables for the local server:
164
178
  - `CODEX_PROXY_PORT`
165
179
  - `CODEX_PROXY_API_KEY`
166
180
  - `CODEX_API_PROXY_HTTPS_PROXY`
181
+ - `CODEX_API_PROXY_CA_BUNDLE`
167
182
  - `CODEX_PROXY_LOG_LEVEL`
168
183
 
169
184
  Token refresh compatibility variables:
@@ -1,5 +1,6 @@
1
1
  from codex_api_proxy.config import DEFAULT_HTTPS_PROXY
2
2
  from codex_api_proxy.config import Settings
3
+ from codex_api_proxy.config import upstream_client
3
4
  from codex_api_proxy.config import upstream_https_proxy
4
5
 
5
6
 
@@ -64,3 +65,52 @@ def test_upstream_https_proxy_defaults_to_privoxy(monkeypatch) -> None:
64
65
  def test_upstream_https_proxy_env_override(monkeypatch) -> None:
65
66
  monkeypatch.setenv("CODEX_API_PROXY_HTTPS_PROXY", "http://127.0.0.1:9999")
66
67
  assert upstream_https_proxy() == "http://127.0.0.1:9999"
68
+
69
+
70
+ def test_upstream_client_defaults_to_system_tls_trust(monkeypatch) -> None:
71
+ for key in ("CODEX_API_PROXY_CA_BUNDLE", "SSL_CERT_FILE", "REQUESTS_CA_BUNDLE"):
72
+ monkeypatch.delenv(key, raising=False)
73
+ captured = {}
74
+
75
+ def fake_async_client(**kwargs):
76
+ captured.update(kwargs)
77
+ return object()
78
+
79
+ monkeypatch.setattr("codex_api_proxy.config.httpx.AsyncClient", fake_async_client)
80
+
81
+ upstream_client()
82
+
83
+ assert captured["verify"] is True
84
+
85
+
86
+ def test_upstream_client_uses_proxy_ca_bundle(monkeypatch) -> None:
87
+ monkeypatch.setenv("CODEX_API_PROXY_CA_BUNDLE", "/etc/ssl/certs/internal-ca.pem")
88
+ monkeypatch.setenv("SSL_CERT_FILE", "/etc/ssl/certs/ignored.pem")
89
+ captured = {}
90
+
91
+ def fake_async_client(**kwargs):
92
+ captured.update(kwargs)
93
+ return object()
94
+
95
+ monkeypatch.setattr("codex_api_proxy.config.httpx.AsyncClient", fake_async_client)
96
+
97
+ upstream_client()
98
+
99
+ assert captured["verify"] == "/etc/ssl/certs/internal-ca.pem"
100
+
101
+
102
+ def test_upstream_client_uses_common_ca_bundle_env(monkeypatch) -> None:
103
+ monkeypatch.delenv("CODEX_API_PROXY_CA_BUNDLE", raising=False)
104
+ monkeypatch.setenv("REQUESTS_CA_BUNDLE", "/etc/ssl/certs/requests-ca.pem")
105
+ monkeypatch.setenv("SSL_CERT_FILE", "/etc/ssl/certs/ssl-ca.pem")
106
+ captured = {}
107
+
108
+ def fake_async_client(**kwargs):
109
+ captured.update(kwargs)
110
+ return object()
111
+
112
+ monkeypatch.setattr("codex_api_proxy.config.httpx.AsyncClient", fake_async_client)
113
+
114
+ upstream_client()
115
+
116
+ assert captured["verify"] == "/etc/ssl/certs/requests-ca.pem"