mirror of
https://github.com/pchuan98/codex.git
synced 2026-07-01 00:31:56 +08: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,4 +1,5 @@
|
||||
use http::HeaderMap;
|
||||
use http::HeaderValue;
|
||||
|
||||
/// Adds authentication headers to API requests.
|
||||
///
|
||||
@@ -8,3 +9,26 @@ use http::HeaderMap;
|
||||
pub trait AuthProvider: Send + Sync {
|
||||
fn add_auth_headers(&self, headers: &mut HeaderMap);
|
||||
}
|
||||
|
||||
pub(crate) fn add_fedramp_routing_header(headers: &mut HeaderMap) {
|
||||
headers.insert("X-OpenAI-Fedramp", HeaderValue::from_static("true"));
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn add_fedramp_routing_header_sets_header() {
|
||||
let mut headers = HeaderMap::new();
|
||||
|
||||
add_fedramp_routing_header(&mut headers);
|
||||
|
||||
assert_eq!(
|
||||
headers
|
||||
.get("X-OpenAI-Fedramp")
|
||||
.and_then(|v| v.to_str().ok()),
|
||||
Some("true")
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user