diff --git a/README.md b/README.md index f3fd6e3..fd3cf10 100644 --- a/README.md +++ b/README.md @@ -41,6 +41,13 @@ The request size limit defaults to 64 MiB. Override it with `CODEX_GATEWAY_MAX_R (pass it with Docker `-e`) or add `--max-request-bytes 67108864` to the executable arguments. See [request limits](docs/common.md). +By default, only basic inference endpoints are exposed. Account, history, +workspace, auth, file storage, Realtime and arbitrary proxy routes return 403. +To enable the full API, pass `--restricted-api` or set +`CODEX_GATEWAY_RESTRICTED_API=true` +(Docker: `-e CODEX_GATEWAY_RESTRICTED_API=true`). See the +[allowed endpoints and account API audit](docs/restricted-api.md). + ## Use Generate text with the official OpenAI Python SDK: diff --git a/docs/common.md b/docs/common.md index 4e038ed..5feadb0 100644 --- a/docs/common.md +++ b/docs/common.md @@ -65,6 +65,7 @@ Gateway errors use this shape; `message` describes the failure: | --- | --- | | 400 | Invalid or unsupported request | | 401 | Missing/wrong gateway key or unavailable subscription credentials | +| 403 | Endpoint disabled by [restricted-api mode](restricted-api.md) | | 404 | Unknown endpoint | | 413 | Request size limit exceeded; some JSON extractor failures use 400 | | 415 | Unsupported media type or native content encoding | diff --git a/docs/native.md b/docs/native.md index d5c8b28..5c3b675 100644 --- a/docs/native.md +++ b/docs/native.md @@ -18,6 +18,11 @@ The gateway uses Codex **0.162.1** and retains the native route inventory audite ## Credentials +By default, only the [inference allowlist](restricted-api.md) is accessible. +Other native routes, including generic proxy paths and account APIs, return +403 before forwarding. Pass `--restricted-api` or set +`CODEX_GATEWAY_RESTRICTED_API=true` to enable them. + Subscription routes use the gateway's Codex credentials. Send `Authorization: Bearer `. The gateway removes caller authorization, account ID and actor-auth headers, then adds the original subscription identity. Subscription authorization is refreshed through Codex's auth manager. Platform, API-key turn costs, personal-token identity, OAuth browser authorization, and remote-control server/pairing routes need their own upstream credentials: diff --git a/docs/restricted-api.md b/docs/restricted-api.md new file mode 100644 index 0000000..72c57ee --- /dev/null +++ b/docs/restricted-api.md @@ -0,0 +1,86 @@ +# Restricted API mode + +By default, the gateway exposes only the inference allowlist below. Account, +stored-data and generic proxy APIs are disabled. To allow these restricted APIs +and enable all gateway routes, pass `--restricted-api` (or +`--restricted-api=true`) or set `CODEX_GATEWAY_RESTRICTED_API=true`. Here the +flag means "allow restricted APIs." Restart the gateway after changing it. + +```sh +# Default: basic inference only. +cargo run --locked --release -- --listen 127.0.0.1:8080 +# Explicitly enable the full API: +cargo run --locked --release -- --restricted-api +# Equivalent environment variable: +CODEX_GATEWAY_RESTRICTED_API=true cargo run --locked --release +``` + +For Docker, pass `-e CODEX_GATEWAY_RESTRICTED_API=true` before the image name +only when the full API is needed. Unset or `false` keeps the default restrictions. +The CLI flag takes precedence over the environment variable; +`--restricted-api=false` explicitly keeps the restrictions enabled. +The gateway key and all existing request limits still apply in either mode. + +## Allowed endpoints + +Only these complete method/path combinations are allowed. Queries do not +change the policy. No wildcard proxy prefix is allowed. + +| Methods | Paths | Purpose | +| --- | --- | --- | +| GET, HEAD | `/healthz` | Gateway health; no gateway key required | +| GET, HEAD | `/v1/models`, `/codex/models`, `/backend-api/codex/models` | Available model catalog | +| POST, GET | `/v1/responses`, `/codex/responses`, `/backend-api/codex/responses` | Inference over HTTP/SSE or WebSocket | +| POST | `/v1/responses/compact`, `/codex/responses/compact`, `/backend-api/codex/responses/compact` | Context compaction | +| POST | `/v1/images/generations`, `/codex/images/generations`, `/backend-api/codex/images/generations` | Image generation | +| POST | `/v1/images/edits`, `/codex/images/edits`, `/backend-api/codex/images/edits` | Image editing | +| POST | `/v1/alpha/search`, `/codex/alpha/search`, `/backend-api/codex/alpha/search` | Standalone search | +| POST | `/v1/audio/transcriptions`, `/transcribe`, `/backend-api/transcribe` | Audio transcription | + +Everything else returns HTTP **403** with `error.code = "endpoint_disabled"`, +including unknown routes, unsupported methods, and new endpoints added later. +Protected requests without a valid gateway key still return 401. Rejection +happens before body extraction, concurrency acquisition, upstream forwarding +or WebSocket upgrade. A trailing slash, encoded path, or extra path component +does not grant access to an unlisted route. + +## Account and stored-data API audit + +The following groups were reviewed against the router, native origin/auth +selection, and all `gateway_paths` in +[`baseline/api-inventory.json`](../baseline/api-inventory.json). All are +disabled in this mode, including aliases. + +| Group | Existing routes or families | Account or data exposure | +| --- | --- | --- | +| Account identity and profiles | `/backend-api/wham/accounts/check`, `/backend-api/wham/profiles/me`; `/api/codex/` aliases | Account membership, capabilities and profile statistics | +| Settings and workspace | `/backend-api/wham/settings/user`, `/backend-api/wham/config/bundle`, `/backend-api/wham/workspace-messages`; `/api/codex/` aliases | User preferences, configuration and workspace content | +| Usage and credits | `/backend-api/wham/usage`, `/backend-api/wham/usage/thread-estimates/query`, `/backend-api/wham/usage/thread_usage/query`, `/backend-api/wham/rate-limit-reset-credits` and `/consume`, `/backend-api/wham/accounts/send_add_credits_nudge_email`; `/api/codex/` aliases | Subscription usage, per-thread estimates, credits and credit-related actions | +| Cloud tasks and environments | `/backend-api/wham/tasks/*`, `/backend-api/wham/tasks`, `/backend-api/wham/environments/*`, `/backend-api/wham/environments`; `/api/codex/` aliases | Tasks, task turns, repository and environment metadata | +| History, notes and memory | `/codex/alpha/history/v2/*`, `/codex/alpha/notes/v2/*`, `/codex/memories/trace_summarize`; `/backend-api/codex/` aliases | Stored conversation history and notes; excluded memory helpers | +| Files and transfers | `/v1/files`, `/backend-api/files`, `/backend-api/files/*`, `/transfers/*` | Account file uploads, upload completion and signed blob capabilities | +| Apps, connectors, plugins and skills | `/backend-api/connectors/*`, `/backend-api/ps/*`, `/backend-api/public/plugins/*`, `/backend-api/plugins/*`, `/api/codex/ps/mcp` | Connected apps, installed/shared plugins, workspace skills and mutation operations | +| Remote control | `/backend-api/wham/remote/control/*`; `/api/codex/` aliases | Enrolled servers, pairing, clients and control channels | +| Authentication and agent identity | `/auth/*`, `/oauth/authorize`, `/backend-api/wham/agent-identities/jwks`; `/api/codex/` alias | Token/device exchanges, revocation, personal-token identity and agent registration | +| Platform proxy | `/platform/*` | Arbitrary public API resources using caller credentials, including stored resources | +| Realtime, live and guardian | `/v1/realtime*`, `/codex/realtime*`, `/backend-api/codex/realtime*`, `/v1/live*`, `/codex/live*`, `/backend-api/codex/live*`, `/codex/guardian`, `/codex/guardian-classifier`; backend aliases | Excluded session/control APIs and specialized inference surfaces | +| Telemetry and distribution | `/telemetry/*`, `/codex/analytics-events/events`, `/backend-api/codex/analytics-events/events`, `/distribution/*`, `/backend-api/wham/app/appcast`; `/api/codex/` alias | Cost reporting, metrics, feedback, updates and assets are outside the minimal surface | +| Generic native forwarding | Unlisted `/backend-api/*`, `/codex/*`, `/api/codex/*`, `/auth/*` paths | Prevents unreviewed or future upstream account APIs from bypassing this mode | + +Some excluded endpoints use the caller's upstream credential rather than the +gateway's subscription, and some serve public data. They remain excluded to +keep the exposed surface explicit and small. + +## Scope + +This is an HTTP endpoint policy. Generation still runs with the configured +ChatGPT subscription and consumes its quota. Model discovery, authentication +refresh and startup device login continue internally; they are not exposed +as caller-accessible authentication routes. + +Model availability, native inference responses, generated files and upstream +headers can still reflect subscription capabilities or inference metadata. +This mode does not redact inference output, isolate callers' upstream state, +or restrict tool execution inside an allowed inference request. +Account-management features in a connected Codex client that need excluded +routes will fail with 403. File uploads and Realtime/live are also unavailable. diff --git a/src/main.rs b/src/main.rs index 8565e15..a76f769 100644 --- a/src/main.rs +++ b/src/main.rs @@ -23,6 +23,11 @@ struct Args { /// Maximum HTTP body, decoded zstd body, and WebSocket message/frame size in bytes. #[arg(long, env = "CODEX_GATEWAY_MAX_REQUEST_BYTES", default_value_t = 64 * 1024 * 1024, value_parser = parse_request_bytes)] max_request_bytes: usize, + /// Allow restricted account, stored-data, and proxy APIs (disabled by default). + #[arg(long, env = "CODEX_GATEWAY_RESTRICTED_API", action = clap::ArgAction::Set, + num_args = 0..=1, require_equals = true, default_missing_value = "true", + default_value_t = false)] + restricted_api: bool, } fn parse_request_bytes(value: &str) -> Result { let bytes = value.parse::().map_err(|e| e.to_string())?; @@ -71,6 +76,7 @@ async fn main() -> anyhow::Result<()> { let telemetry = tokio::task::spawn_blocking(codex_api_gateway::telemetry::Telemetry::from_env).await??; let gateway = Gateway { + allow_restricted_api: args.restricted_api, telemetry: telemetry.clone(), backend, models, @@ -83,7 +89,7 @@ async fn main() -> anyhow::Result<()> { transfers, }; let listener = tokio::net::TcpListener::bind(args.listen).await?; - tracing::info!(listen=%listener.local_addr()?, "Codex Responses gateway ready"); + tracing::info!(listen=%listener.local_addr()?, allow_restricted_api=args.restricted_api, "Codex Responses gateway ready"); axum::serve(listener, router(gateway)) .with_graceful_shutdown(async { #[cfg(unix)] @@ -107,6 +113,34 @@ async fn main() -> anyhow::Result<()> { mod tests { use super::*; + #[test] + fn full_api_is_opt_in() { + // Inspect the CLI definition so an inherited environment cannot change + // the assertion about the default, or mask a missing flag. + use clap::CommandFactory; + let command = Args::command(); + let argument = command + .get_arguments() + .find(|arg| arg.get_id() == "restricted_api") + .unwrap(); + assert_eq!(argument.get_long(), Some("restricted-api")); + assert_eq!( + argument.get_env(), + Some(std::ffi::OsStr::new("CODEX_GATEWAY_RESTRICTED_API")) + ); + let defaults = command + .mut_arg("restricted_api", |arg| arg.env(None::<&str>)) + .try_get_matches_from(["gateway"]) + .unwrap(); + assert!(!defaults.get_flag("restricted_api")); + for flag in ["--restricted-api", "--restricted-api=true"] { + let args = Args::try_parse_from(["gateway", flag]).unwrap(); + assert!(args.restricted_api); + } + let args = Args::try_parse_from(["gateway", "--restricted-api=false"]).unwrap(); + assert!(!args.restricted_api); + } + #[test] fn request_limit_defaults_to_64_mib() { use clap::CommandFactory; diff --git a/src/server.rs b/src/server.rs index 1be6922..6e7053d 100644 --- a/src/server.rs +++ b/src/server.rs @@ -4,6 +4,7 @@ use axum::{ body::Body, extract::{DefaultBodyLimit, Query, State, rejection::JsonRejection}, http::{HeaderMap, StatusCode}, + middleware::{self, Next}, response::{IntoResponse, Response}, routing::{get, post}, }; @@ -14,6 +15,7 @@ use std::{sync::Arc, time::Duration}; use tokio::sync::Semaphore; pub struct Gateway { + pub allow_restricted_api: bool, pub backend: Backend, pub models: Vec, pub key: Option, @@ -25,6 +27,8 @@ pub struct Gateway { } pub fn router(gateway: Gateway) -> Router { + let max_request_bytes = gateway.max_request_bytes; + let gateway = Arc::new(gateway); Router::new() .route( "/healthz", @@ -72,8 +76,58 @@ pub fn router(gateway: Gateway) -> Router { .route("/v1/live/sessions/{session_id}/attach", get(crate::realtime::upgrade)) .route("/transfers/{handle}", axum::routing::any(transfer)) .fallback(crate::native::handle) - .layer(DefaultBodyLimit::max(gateway.max_request_bytes)) - .with_state(Arc::new(gateway)) + .layer(DefaultBodyLimit::max(max_request_bytes)) + .layer(middleware::from_fn_with_state(gateway.clone(), restricted_api_policy)) + .with_state(gateway) +} + +// Match complete paths and methods, including native aliases. New routes and +// arbitrary proxy paths stay closed until explicitly reviewed for this mode. +fn is_allowed_restricted_api(method: &http::Method, path: &str) -> bool { + use http::Method; + match path { + "/healthz" | "/v1/models" | "/codex/models" | "/backend-api/codex/models" => { + method == Method::GET || method == Method::HEAD + } + "/v1/responses" | "/codex/responses" | "/backend-api/codex/responses" => { + method == Method::POST || method == Method::GET + } + "/v1/responses/compact" + | "/codex/responses/compact" + | "/backend-api/codex/responses/compact" + | "/v1/images/generations" + | "/v1/images/edits" + | "/codex/images/generations" + | "/codex/images/edits" + | "/backend-api/codex/images/generations" + | "/backend-api/codex/images/edits" + | "/v1/alpha/search" + | "/codex/alpha/search" + | "/backend-api/codex/alpha/search" + | "/v1/audio/transcriptions" + | "/transcribe" + | "/backend-api/transcribe" => method == Method::POST, + _ => false, + } +} + +async fn restricted_api_policy( + State(gateway): State>, + request: axum::extract::Request, + next: Next, +) -> Result { + if !gateway.allow_restricted_api + && !is_allowed_restricted_api(request.method(), request.uri().path()) + { + authorize(&gateway, request.headers())?; + return Err(GatewayError { + upstream_response: None, + status: StatusCode::FORBIDDEN, + code: "endpoint_disabled", + message: "endpoint disabled; enable full API access with --restricted-api".into(), + }); + } + Ok(next.run(request).await) } async fn transfer( State(gateway): State>, diff --git a/tests/cases/restricted_api.rs b/tests/cases/restricted_api.rs new file mode 100644 index 0000000..e4d79ac --- /dev/null +++ b/tests/cases/restricted_api.rs @@ -0,0 +1,316 @@ +use super::*; + +async fn restricted_harness() -> Harness { + restricted_harness_with_events(events()).await +} + +async fn restricted_harness_with_events(events: Vec) -> Harness { + Harness::with_api_policy( + events, + StatusCode::OK, + false, + Duration::from_secs(5), + CodexAuth::create_dummy_chatgpt_auth_for_testing(), + true, + 16 * 1024 * 1024, + false, + ) + .await +} + +#[tokio::test] +async fn full_api_explicitly_enables_account_and_stored_data_routes() { + let h = Harness::with_api_policy( + vec![], + StatusCode::OK, + false, + Duration::from_secs(5), + CodexAuth::create_dummy_chatgpt_auth_for_testing(), + false, + 16 * 1024 * 1024, + true, + ) + .await; + let client = reqwest::Client::new(); + for path in [ + "/backend-api/wham/profiles/me", + "/api/codex/accounts/check", + "/codex/alpha/history/v2/read_item", + "/backend-api/codex/alpha/notes/v2/read_file", + ] { + let response = client + .get(format!("{}{path}", h.url)) + .bearer_auth("client-key") + .send() + .await + .unwrap(); + assert_eq!(response.status(), StatusCode::OK, "{path}"); + } + assert_eq!(h.fake.received.lock().unwrap().len(), 4); +} + +#[tokio::test] +async fn restricted_api_blocks_inventoried_routes_and_aliases_before_upstream() { + let h = restricted_harness().await; + let inventory: Value = + serde_json::from_str(include_str!("../../baseline/api-inventory.json")).unwrap(); + let client = reqwest::Client::new(); + let mut checked = 0; + for entry in inventory["entries"].as_array().unwrap() { + if matches!( + entry["id"].as_str().unwrap(), + "responses" + | "models" + | "image-generations" + | "image-edits" + | "search" + | "historical-audio-transcription" + ) { + continue; + } + for path in entry["gateway_paths"].as_array().unwrap() { + let path = path + .as_str() + .unwrap() + .split('/') + .map(|part| { + if part.starts_with('{') { + "opaque-id" + } else { + part + } + }) + .collect::>() + .join("/"); + for method in entry["methods"].as_array().unwrap() { + let response = client + .request( + reqwest::Method::from_bytes(method.as_str().unwrap().as_bytes()).unwrap(), + format!("{}{path}?future=true", h.url), + ) + .bearer_auth("client-key") + .body("must not reach upstream") + .send() + .await + .unwrap(); + assert_eq!(response.status(), StatusCode::FORBIDDEN, "{method} {path}"); + assert_eq!( + response.json::().await.unwrap()["error"]["code"], + "endpoint_disabled" + ); + checked += 1; + } + } + } + assert!(checked > 100, "checked {checked} inventory routes"); + assert!(h.fake.http_bodies.lock().unwrap().is_empty()); + assert_eq!( + h.fake + .ws_connections + .load(std::sync::atomic::Ordering::SeqCst), + 0 + ); +} + +#[tokio::test] +async fn restricted_api_denies_unlisted_paths_methods_and_proxy_escape_routes() { + let h = restricted_harness().await; + let client = reqwest::Client::new(); + for path in [ + "/v1/files", + "/v1/realtime/calls", + "/codex/live/sessions", + "/backend-api/codex/live/sessions/session/attach", + "/transfers/opaque-handle", + "/platform/responses", + "/platform/organizations", + "/backend-api/future-account-endpoint", + "/codex/future-account-endpoint", + "/api/codex/future-account-endpoint", + "/auth/future-account-endpoint", + "/v1/responses/resp_saved", + "/v1/responses/", + "/codex/responses/extra", + "/codex/%72esponses", + "/codex/responses%2f..%2fwham/usage", + "/codex//responses", + "/v1/audio/sessions", + "/unknown", + ] { + let response = client + .post(format!("{}{path}", h.url)) + .bearer_auth("client-key") + .send() + .await + .unwrap(); + assert_eq!(response.status(), StatusCode::FORBIDDEN, "{path}"); + } + for method in [ + reqwest::Method::DELETE, + reqwest::Method::PUT, + reqwest::Method::PATCH, + ] { + let response = client + .request(method, format!("{}/codex/responses", h.url)) + .bearer_auth("client-key") + .send() + .await + .unwrap(); + assert_eq!(response.status(), StatusCode::FORBIDDEN); + } + let response = client + .get(format!("{}/api/codex/usage", h.url)) + .send() + .await + .unwrap(); + assert_eq!(response.status(), StatusCode::UNAUTHORIZED); + assert!(h.fake.http_bodies.lock().unwrap().is_empty()); +} + +#[tokio::test] +async fn restricted_api_keeps_models_responses_and_websockets_working() { + use futures::{SinkExt, StreamExt}; + use tokio_tungstenite::tungstenite::{Message, client::IntoClientRequest}; + + let h = restricted_harness().await; + let client = reqwest::Client::new(); + assert_eq!( + client + .get(format!("{}/healthz", h.url)) + .send() + .await + .unwrap() + .status(), + StatusCode::OK + ); + for prefix in ["v1", "codex", "backend-api/codex"] { + let response = client + .get(format!("{}/{prefix}/models?client_version=0.163.0", h.url)) + .bearer_auth("client-key") + .send() + .await + .unwrap(); + assert_eq!(response.status(), StatusCode::OK, "{prefix} models"); + let body = response.json::().await.unwrap(); + assert!(body["models"].is_array()); + + let response = client + .post(format!("{}/{prefix}/responses", h.url)) + .bearer_auth("client-key") + .json(&json!({"model":h.model,"input":"hello","stream":true})) + .send() + .await + .unwrap(); + assert_eq!(response.status(), StatusCode::OK, "{prefix} responses"); + assert!( + response + .text() + .await + .unwrap() + .contains("response.completed") + ); + + let mut request = format!("{}/{prefix}/responses", h.url) + .replacen("http:", "ws:", 1) + .into_client_request() + .unwrap(); + request + .headers_mut() + .insert("authorization", "Bearer client-key".parse().unwrap()); + let (mut socket, _) = tokio_tungstenite::connect_async(request).await.unwrap(); + socket + .send(Message::Text( + json!({"type":"response.create","model":h.model,"input":[],"stream":true}) + .to_string() + .into(), + )) + .await + .unwrap(); + assert!(socket.next().await.unwrap().unwrap().is_text()); + socket.close(None).await.unwrap(); + } +} + +#[tokio::test] +async fn restricted_api_keeps_standalone_inference_aliases() { + let h = restricted_harness().await; + let client = reqwest::Client::new(); + // Invalid inputs must reach each specialized handler's validation, rather + // than being rejected by the access policy or sent to a generic proxy. + for suffix in ["images/generations", "images/edits", "alpha/search"] { + for prefix in ["v1", "codex", "backend-api/codex"] { + let response = client + .post(format!("{}/{prefix}/{suffix}", h.url)) + .bearer_auth("client-key") + .json(&json!({})) + .send() + .await + .unwrap(); + assert!( + matches!( + response.status(), + StatusCode::BAD_REQUEST | StatusCode::UNPROCESSABLE_ENTITY + ), + "{prefix}/{suffix}: {}", + response.status() + ); + } + } + for path in [ + "/transcribe", + "/v1/audio/transcriptions", + "/backend-api/transcribe", + ] { + let response = client + .post(format!("{}{path}", h.url)) + .bearer_auth("client-key") + .header("content-type", "multipart/form-data; boundary=test") + .body("--test--\r\n") + .send() + .await + .unwrap(); + assert_eq!(response.status(), StatusCode::OK, "{path}"); + } + assert_eq!(h.fake.http_bodies.lock().unwrap().len(), 3); +} + +#[tokio::test] +async fn restricted_api_keeps_compaction_and_image_and_search_generation() { + let h = restricted_harness_with_events(vec![completed(vec![json!({ + "type":"compaction", "id":"cmp_1", "encrypted_content":"encrypted-compaction" + })])]) + .await; + let client = reqwest::Client::new(); + for prefix in ["v1", "codex", "backend-api/codex"] { + for (suffix, body) in [ + ( + "images/generations", + json!({"model":"gpt-image-2","prompt":"a square"}), + ), + ( + "images/edits", + json!({"model":"gpt-image-2","prompt":"a blue square","images":[{"image_url":format!("data:image/png;base64,{}", tool_cases::IMAGE_PNG)}]}), + ), + ( + "alpha/search", + json!({"id":"search-session","model":h.model,"input":"Find Codex"}), + ), + ( + "responses/compact", + json!({"model":h.model,"input":[{"role":"user","content":"compress"}]}), + ), + ] { + let response = client + .post(format!("{}/{prefix}/{suffix}", h.url)) + .bearer_auth("client-key") + .json(&body) + .send() + .await + .unwrap(); + let status = response.status(); + let output = response.text().await.unwrap(); + assert_eq!(status, StatusCode::OK, "{prefix}/{suffix}: {output}"); + assert!(!output.is_empty()); + } + } +} diff --git a/tests/catalog.rs b/tests/catalog.rs index e50623a..8e7d3db 100644 --- a/tests/catalog.rs +++ b/tests/catalog.rs @@ -73,6 +73,7 @@ async fn startup_catalog_exposes_new_models_and_uses_their_capabilities() { ); } let app = router(Gateway { + allow_restricted_api: false, max_request_bytes: 16 * 1024 * 1024, telemetry: None, backend, diff --git a/tests/gateway.rs b/tests/gateway.rs index 7ba381f..8a0fedc 100644 --- a/tests/gateway.rs +++ b/tests/gateway.rs @@ -2,6 +2,8 @@ mod file_cases; #[path = "cases/native.rs"] mod native_cases; +#[path = "cases/restricted_api.rs"] +mod restricted_api_cases; mod support; use axum::{ Router, @@ -222,6 +224,28 @@ impl Harness { login: CodexAuth, transfers: bool, max_request_bytes: usize, + ) -> Self { + Self::with_api_policy( + events, + status, + hang, + timeout, + login, + transfers, + max_request_bytes, + true, + ) + .await + } + async fn with_api_policy( + events: Vec, + status: StatusCode, + hang: bool, + timeout: Duration, + login: CodexAuth, + transfers: bool, + max_request_bytes: usize, + allow_restricted_api: bool, ) -> Self { let subscription = login.is_chatgpt_auth(); let fake = Fake { @@ -326,6 +350,7 @@ impl Harness { .unwrap() }); let app = router(Gateway { + allow_restricted_api, max_request_bytes, telemetry: None, backend, diff --git a/tests/support/live_gateway.rs b/tests/support/live_gateway.rs index 3be2bd3..511ba21 100644 --- a/tests/support/live_gateway.rs +++ b/tests/support/live_gateway.rs @@ -53,6 +53,7 @@ impl LiveGateway { let model_catalog = Some(models.clone()); let observed = transports.clone(); let app = router(Gateway { + allow_restricted_api: true, max_request_bytes: 16 * 1024 * 1024, telemetry: None, backend,