let codex force ChatGPT login by org too

Add forced_chatgpt_org_id config parsing, runtime validation, and mutual exclusion with forced_chatgpt_workspace_id.\n\nThread org restrictions through browser and device-code login flows, auth enforcement, local auth loading, and app-server config schemas, with focused regression coverage for org restriction handling.
This commit is contained in:
rreichel3-oai
2026-04-17 16:19:48 -04:00
parent 9545da13a7
commit 4a144dae80
24 changed files with 366 additions and 29 deletions
+8
View File
@@ -113,12 +113,14 @@ fn print_login_server_start(actual_port: u16, auth_url: &str) {
pub async fn login_with_chatgpt(
codex_home: PathBuf,
forced_chatgpt_workspace_id: Option<Vec<String>>,
forced_chatgpt_org_id: Option<Vec<String>>,
cli_auth_credentials_store_mode: AuthCredentialsStoreMode,
) -> std::io::Result<()> {
let opts = ServerOptions::new(
codex_home,
CLIENT_ID.to_string(),
forced_chatgpt_workspace_id,
forced_chatgpt_org_id,
cli_auth_credentials_store_mode,
);
let server = run_login_server(opts)?;
@@ -139,10 +141,12 @@ pub async fn run_login_with_chatgpt(cli_config_overrides: CliConfigOverrides) ->
}
let forced_chatgpt_workspace_id = config.forced_chatgpt_workspace_id.clone();
let forced_chatgpt_org_id = config.forced_chatgpt_org_id.clone();
match login_with_chatgpt(
config.codex_home.to_path_buf(),
forced_chatgpt_workspace_id,
forced_chatgpt_org_id,
config.cli_auth_credentials_store_mode,
)
.await
@@ -228,10 +232,12 @@ pub async fn run_login_with_device_code(
std::process::exit(1);
}
let forced_chatgpt_workspace_id = config.forced_chatgpt_workspace_id.clone();
let forced_chatgpt_org_id = config.forced_chatgpt_org_id.clone();
let mut opts = ServerOptions::new(
config.codex_home.to_path_buf(),
client_id.unwrap_or(CLIENT_ID.to_string()),
forced_chatgpt_workspace_id,
forced_chatgpt_org_id,
config.cli_auth_credentials_store_mode,
);
if let Some(iss) = issuer_base_url {
@@ -267,10 +273,12 @@ pub async fn run_login_with_device_code_fallback_to_browser(
}
let forced_chatgpt_workspace_id = config.forced_chatgpt_workspace_id.clone();
let forced_chatgpt_org_id = config.forced_chatgpt_org_id.clone();
let mut opts = ServerOptions::new(
config.codex_home.to_path_buf(),
client_id.unwrap_or(CLIENT_ID.to_string()),
forced_chatgpt_workspace_id,
forced_chatgpt_org_id,
config.cli_auth_credentials_store_mode,
);
if let Some(iss) = issuer_base_url {