mirror of
https://github.com/openai/codex.git
synced 2026-11-25 23:30:49 +00:00
Add experimental ChatGPT workspace switching to app-server (#57514)
## What changed - Add `accountSession/list` and `accountSession/switch` for the active managed ChatGPT login, with optional workspace membership refresh. - Validate membership and workspace policy, pause new turns, and unload running threads before switching credentials. Notify clients with `thread/closed` and `account/updated`; selecting the current workspace leaves threads running. - Support browser sign-in for SSO through `allowBrowserLogin`, binding the callback to the requesting login and workspace. Require a separate sign-in for government workspaces. - Preserve the selected workspace across token refresh and conditionally restore the previous workspace if routing validation fails. Guard credential writes against concurrent login or logout changes. ## Testing Add app-server and auth tests covering workspace switching, credential preservation, policy and identity rejection, conditional rollback, stale sessions, and SSO callback validation. GitOrigin-RevId: 1234abc33b71e69b66318da3e201fccc08867906
This commit is contained in:
committed by
copyberry
parent
27ace641fe
commit
d257beb16a
@@ -136,6 +136,12 @@ pub struct AccountsCheckResponse {
|
||||
#[derive(Clone, Debug, Deserialize)]
|
||||
pub struct AccountEntry {
|
||||
pub id: String,
|
||||
pub can_access_with_session: Option<bool>,
|
||||
pub sso_connection_name: Option<String>,
|
||||
#[serde(default)]
|
||||
pub is_deactivated: bool,
|
||||
#[serde(default)]
|
||||
pub is_fedramp_compliant_workspace: bool,
|
||||
/// Current subscription reported by the accounts endpoint, independent of token claims.
|
||||
#[serde(default)]
|
||||
pub plan_type: Option<codex_protocol::account::PlanType>,
|
||||
@@ -175,12 +181,18 @@ impl Default for RawAccounts {
|
||||
#[derive(Deserialize)]
|
||||
struct ChatGptAccountEntry {
|
||||
account: ChatGptAccountInfo,
|
||||
can_access_with_session: Option<bool>,
|
||||
sso_connection_name: Option<String>,
|
||||
}
|
||||
|
||||
#[derive(Deserialize)]
|
||||
struct ChatGptAccountInfo {
|
||||
account_id: Option<String>,
|
||||
#[serde(default)]
|
||||
is_deactivated: bool,
|
||||
#[serde(default)]
|
||||
is_fedramp_compliant_workspace: bool,
|
||||
#[serde(default)]
|
||||
plan_type: Option<codex_protocol::account::PlanType>,
|
||||
#[serde(default)]
|
||||
name: Option<String>,
|
||||
@@ -202,9 +214,14 @@ impl<'de> Deserialize<'de> for AccountsCheckResponse {
|
||||
.account_ordering
|
||||
.iter()
|
||||
.filter_map(|account_id| {
|
||||
let account = accounts.remove(account_id)?.account;
|
||||
let entry = accounts.remove(account_id)?;
|
||||
let account = entry.account;
|
||||
Some(AccountEntry {
|
||||
id: account.account_id?,
|
||||
can_access_with_session: entry.can_access_with_session,
|
||||
sso_connection_name: entry.sso_connection_name,
|
||||
is_deactivated: account.is_deactivated,
|
||||
is_fedramp_compliant_workspace: account.is_fedramp_compliant_workspace,
|
||||
plan_type: account.plan_type,
|
||||
workspace_backend_origin: None,
|
||||
account_routing_override: None,
|
||||
|
||||
Reference in New Issue
Block a user