mirror of
https://github.com/openai/codex.git
synced 2026-11-19 23:05:23 +00:00
[codex] Route Fed ChatGPT auth through Fed edge (#17151)
## Summary - parse chatgpt_account_is_fedramp from signed ChatGPT auth metadata - add _account_is_fedramp=true to ChatGPT backend-api requests only for FedRAMP ChatGPT-auth accounts
This commit is contained in:
1 parent
4cd85b28d2
commit
f97be7dfff
11 files changed
+103
No files matched your search
@@ -104,6 +104,7 @@ pub struct Client {
|
||||
bearer_token: Option<String>,
|
||||
user_agent: Option<HeaderValue>,
|
||||
chatgpt_account_id: Option<String>,
|
||||
chatgpt_account_is_fedramp: bool,
|
||||
path_style: PathStyle,
|
||||
}
|
||||
|
||||
@@ -129,6 +130,7 @@ impl Client {
|
||||
bearer_token: None,
|
||||
user_agent: None,
|
||||
chatgpt_account_id: None,
|
||||
chatgpt_account_is_fedramp: false,
|
||||
path_style,
|
||||
})
|
||||
}
|
||||
@@ -141,6 +143,9 @@ impl Client {
|
||||
if let Some(account_id) = auth.get_account_id() {
|
||||
client = client.with_chatgpt_account_id(account_id);
|
||||
}
|
||||
if auth.is_fedramp_account() {
|
||||
client = client.with_fedramp_routing_header();
|
||||
}
|
||||
Ok(client)
|
||||
}
|
||||
|
||||
@@ -161,6 +166,11 @@ impl Client {
|
||||
self
|
||||
}
|
||||
|
||||
pub fn with_fedramp_routing_header(mut self) -> Self {
|
||||
self.chatgpt_account_is_fedramp = true;
|
||||
self
|
||||
}
|
||||
|
||||
pub fn with_path_style(mut self, style: PathStyle) -> Self {
|
||||
self.path_style = style;
|
||||
self
|
||||
@@ -185,6 +195,11 @@ impl Client {
|
||||
{
|
||||
h.insert(name, hv);
|
||||
}
|
||||
if self.chatgpt_account_is_fedramp
|
||||
&& let Ok(name) = HeaderName::from_bytes(b"X-OpenAI-Fedramp")
|
||||
{
|
||||
h.insert(name, HeaderValue::from_static("true"));
|
||||
}
|
||||
h
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user