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:
Winston Howes
2026-08-24 22:10:44 +00:00
committed by copyberry
parent 4f6d43c267
commit 0280d73c1e
8 changed files with 566 additions and 42 deletions
+13
View File
@@ -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);
}