mirror of
https://github.com/openai/codex.git
synced 2026-11-27 23:31:09 +00:00
Handle Amazon Bedrock credentials during logout (#33175)
## Why Amazon Bedrock can use either a Codex-managed API key or credentials managed by AWS, so logout must not remove or misrepresent credentials that Codex does not control. ## What changed - Remove the managed Bedrock key on logout and clear `model_provider` only when its user-config value is still `amazon-bedrock`. - Reject logout for AWS-managed Bedrock credentials without changing existing authentication or configuration. - Add a `test-logout` app-server test-client command that waits for the resulting `account/updated` notification. ## Testing Add coverage for managed and AWS-managed Bedrock logout, concurrent provider changes, config reload failures, and conditional user-config cleanup. GitOrigin-RevId: a003c0ec27ad7b36d499fe7b63ab4a0dd6369b4f
This commit is contained in:
1 parent
c38c30ef51
commit
6e215e0db5
8 files changed
+384
-16
No files matched your search
@@ -46,6 +46,7 @@ use codex_app_server_protocol::JSONRPCNotification;
|
||||
use codex_app_server_protocol::JSONRPCRequest;
|
||||
use codex_app_server_protocol::JSONRPCResponse;
|
||||
use codex_app_server_protocol::LoginAccountResponse;
|
||||
use codex_app_server_protocol::LogoutAccountResponse;
|
||||
use codex_app_server_protocol::ModelListParams;
|
||||
use codex_app_server_protocol::ModelListResponse;
|
||||
use codex_app_server_protocol::RequestId;
|
||||
@@ -245,6 +246,8 @@ enum CliCommand {
|
||||
#[arg(long, value_name = "REGION")]
|
||||
region: Option<String>,
|
||||
},
|
||||
/// Log out of the current account and wait for the account update.
|
||||
TestLogout,
|
||||
/// Fetch the current account rate limits from the Codex app-server.
|
||||
GetAccountRateLimits,
|
||||
/// List the available models from the Codex app-server.
|
||||
@@ -449,6 +452,11 @@ pub async fn run() -> Result<()> {
|
||||
};
|
||||
test_login(&endpoint, &config_overrides, mode).await
|
||||
}
|
||||
CliCommand::TestLogout => {
|
||||
ensure_dynamic_tools_unused(&dynamic_tools, "test-logout")?;
|
||||
let endpoint = resolve_endpoint(codex_bin, url)?;
|
||||
test_logout(&endpoint, &config_overrides).await
|
||||
}
|
||||
CliCommand::GetAccountRateLimits => {
|
||||
ensure_dynamic_tools_unused(&dynamic_tools, "get-account-rate-limits")?;
|
||||
let endpoint = resolve_endpoint(codex_bin, url)?;
|
||||
@@ -1253,6 +1261,27 @@ async fn get_account_rate_limits(endpoint: &Endpoint, config_overrides: &[String
|
||||
.await
|
||||
}
|
||||
|
||||
async fn test_logout(endpoint: &Endpoint, config_overrides: &[String]) -> Result<()> {
|
||||
with_client("test-logout", endpoint, config_overrides, |client| {
|
||||
let initialize = client.initialize()?;
|
||||
println!("< initialize response: {initialize:?}");
|
||||
|
||||
let response = client.logout_account()?;
|
||||
println!("< account/logout response: {response:?}");
|
||||
|
||||
loop {
|
||||
let notification = client.next_notification()?;
|
||||
if let Ok(ServerNotification::AccountUpdated(account_updated)) =
|
||||
ServerNotification::try_from(notification)
|
||||
{
|
||||
println!("< account/updated notification: {account_updated:?}");
|
||||
return Ok(());
|
||||
}
|
||||
}
|
||||
})
|
||||
.await
|
||||
}
|
||||
|
||||
async fn model_list(endpoint: &Endpoint, config_overrides: &[String]) -> Result<()> {
|
||||
with_client("model-list", endpoint, config_overrides, |client| {
|
||||
let initialize = client.initialize()?;
|
||||
@@ -1809,6 +1838,16 @@ impl CodexClient {
|
||||
self.send_request(request, request_id, "account/rateLimits/read")
|
||||
}
|
||||
|
||||
fn logout_account(&mut self) -> Result<LogoutAccountResponse> {
|
||||
let request_id = self.request_id();
|
||||
let request = ClientRequest::LogoutAccount {
|
||||
request_id: request_id.clone(),
|
||||
params: None,
|
||||
};
|
||||
|
||||
self.send_request(request, request_id, "account/logout")
|
||||
}
|
||||
|
||||
fn model_list(&mut self, params: ModelListParams) -> Result<ModelListResponse> {
|
||||
let request_id = self.request_id();
|
||||
let request = ClientRequest::ModelList {
|
||||
|
||||
Reference in new issue
Block a user