mirror of
https://github.com/openai/codex.git
synced 2026-11-17 22:10:37 +00:00
Enable GitHub Actions OIDC authentication in the Responses API proxy (#55320)
## Why GitHub Actions workflows can use short-lived OpenAI credentials instead of storing a long-lived OpenAI API key in GitHub secrets. ## What changed - Add `--github-oidc` with required audience, identity provider, service account, and GitHub token-request URL settings. Read the GitHub request credential from stdin and connect it to the existing federated authentication flow. - Require the default OpenAI Responses endpoint in OIDC mode before reading credentials, and complete the initial token exchange before publishing server info. - Close the npm launcher's copy of stdin after the native child starts. - Document OIDC setup, credential handling, renewal behavior, and caller responsibilities. Keep API-key authentication as the default. ## Testing Add tests for required OIDC flags, upstream restrictions before credential reads, rejection of unsafe or empty settings without exposing sensitive input, and failure when a configured custom CA cannot be loaded in the CLI blocking context. GitOrigin-RevId: 7de6fd4c3491e7ccd6a2c2ccdee0bc2eedd0e642
This commit is contained in:
@@ -33,6 +33,8 @@ use tokio::runtime::Runtime;
|
||||
use url::Url;
|
||||
use zeroize::Zeroizing;
|
||||
|
||||
use crate::OPENAI_RESPONSES_URL;
|
||||
|
||||
const OPENAI_TOKEN_URL: &str = "https://auth.openai.com/oauth/token";
|
||||
pub(crate) const MAX_TOKEN_BYTES: usize = 16 * 1024;
|
||||
const MAX_RESPONSE_BYTES: usize = 64 * 1024;
|
||||
@@ -117,7 +119,16 @@ impl AuthHeader {
|
||||
}
|
||||
|
||||
impl Auth {
|
||||
#[cfg_attr(not(test), allow(dead_code, reason = "used by a later stack layer"))]
|
||||
/// Must be checked before reading any source credential, including stdin.
|
||||
pub(crate) fn validate_federated_upstream(upstream: &str) -> Result<()> {
|
||||
if upstream != OPENAI_RESPONSES_URL {
|
||||
return Err(anyhow!(
|
||||
"workload identity requires the default OpenAI Responses endpoint"
|
||||
));
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub(crate) fn federated(
|
||||
source: impl SubjectTokenSource + 'static,
|
||||
provider: String,
|
||||
|
||||
Reference in New Issue
Block a user