mirror of
https://github.com/openai/codex.git
synced 2026-10-20 17:38:45 +00:00
Broker credential aliases in child environments (#40484)
## What changed - Discover supported credentials inherited from the parent even when their canonical provider variable is filtered from the child environment. - Replace matching values and credentials embedded in longer child environment values with broker dummies, then restore only aliases that the broker virtualized. - Preserve provider and host bindings when selecting credentials for outbound requests, including GitHub Enterprise and custom OpenAI hosts. - Expose helpers for identifying provider and binding variables, plus an API for virtualizing credential-bearing text before it is persisted. ## Testing - Extend credential broker tests for filtered parent variables, exact and embedded aliases, text virtualization, user overrides, and host-bound GitHub and OpenAI credentials. GitOrigin-RevId: 55d673911900470aab4e206d0f4f5e62ed3611ae
This commit is contained in:
@@ -427,6 +427,11 @@ impl NetworkProxyState {
|
||||
}
|
||||
|
||||
pub fn virtualize_child_credentials(&self, env: &mut HashMap<String, String>) {
|
||||
let parent_env = std::env::vars_os()
|
||||
.filter_map(|(key, value)| Some((key.into_string().ok()?, value.into_string().ok()?)))
|
||||
.collect();
|
||||
self.credential_broker
|
||||
.discover_parent_credentials(&parent_env, env);
|
||||
self.credential_broker.virtualize_child_env(env);
|
||||
}
|
||||
|
||||
@@ -438,6 +443,14 @@ impl NetworkProxyState {
|
||||
self.credential_broker.restore_child_env(env, command);
|
||||
}
|
||||
|
||||
pub(crate) fn virtualize_brokered_text(
|
||||
&self,
|
||||
text: &mut String,
|
||||
env: &HashMap<String, String>,
|
||||
) -> bool {
|
||||
self.credential_broker.virtualize_text(text, env)
|
||||
}
|
||||
|
||||
pub fn inject_request_credentials(&self, host: &str, headers: &mut rama_http::HeaderMap) {
|
||||
self.credential_broker.inject_request_headers(host, headers);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user