mirror of
https://github.com/openai/codex.git
synced 2026-11-23 23:10:47 +00:00
Use runtime authentication across backend request paths (#59572)
## What changed - Share the harness runtime identity with analytics delivery and turn-cost queries, and resolve request authentication together with its account-bound transport policy. - Add runtime authentication to ChatGPT request helpers and `codex cloud`, including environment discovery. Resolve environment credentials for each request and honor CLI configuration overrides when loading cloud authentication. - Preserve custom-backend authentication, validate runtime destinations, and keep cloud requests from following redirects. - Forward only organization and project selectors from model-provider headers to API-key analytics requests. ## Testing Add regression coverage for runtime request signing, credential refresh, account and resource selection, redirect credential handling, custom destinations, and cloud credential-store overrides. GitOrigin-RevId: 75f33961ee6482881e9ff9817e99d977f31b65b8
This commit is contained in:
@@ -11,7 +11,7 @@ use wiremock::matchers::header;
|
||||
use wiremock::matchers::path;
|
||||
|
||||
#[tokio::test]
|
||||
async fn cloud_list_only_allows_trusted_credential_destinations() -> Result<()> {
|
||||
async fn cloud_list_respects_the_credential_store_and_trusted_destinations() -> Result<()> {
|
||||
let server = MockServer::start().await;
|
||||
let codex_home = TempDir::new()?;
|
||||
std::fs::write(
|
||||
@@ -66,6 +66,28 @@ async fn cloud_list_only_allows_trusted_credential_destinations() -> Result<()>
|
||||
insta::assert_snapshot!(String::from_utf8(output)?, @"Error: CODEX_CLOUD_TASKS_BASE_URL must use a trusted HTTPS origin on port 443, without user information, a query, or a fragment; custom backends cannot use saved ChatGPT credentials");
|
||||
assert!(server.received_requests().await.unwrap().is_empty());
|
||||
|
||||
// An explicit ephemeral store must exclude the saved login for Cloud itself.
|
||||
command()?
|
||||
.env(
|
||||
"CODEX_CLOUD_TASKS_BASE_URL",
|
||||
"https://chatgpt-staging.com/backend-api",
|
||||
)
|
||||
.env("HTTPS_PROXY", server.uri())
|
||||
.env("https_proxy", server.uri())
|
||||
.args([
|
||||
"-c",
|
||||
"cli_auth_credentials_store='ephemeral'",
|
||||
"cloud",
|
||||
"list",
|
||||
"--limit",
|
||||
"1",
|
||||
"--json",
|
||||
])
|
||||
.assert()
|
||||
.failure()
|
||||
.stderr(contains("Not signed in. Please run 'codex login'"));
|
||||
assert!(server.received_requests().await.unwrap().is_empty());
|
||||
|
||||
// Staging must reach explicit PAT authentication. Reject the synthetic PAT locally so
|
||||
// this test never sends a request to the real staging backend.
|
||||
let auth_server = MockServer::start().await;
|
||||
|
||||
Reference in New Issue
Block a user