Compare commits

...

2 Commits

Author SHA1 Message Date
mikhail-oai
3eafdd33ae Default auth and credential storage to keyring 2026-02-15 19:44:20 -05:00
mikhail-oai
0b74e4093e Use keyring as default CLI auth store on macOS 2026-02-15 18:47:58 -05:00
4 changed files with 18 additions and 18 deletions

View File

@@ -643,7 +643,7 @@
"type": "string"
},
{
"description": "Keyring when available, otherwise fail.",
"description": "Keyring when available, otherwise fail. This is the default storage mode.",
"enum": [
"keyring"
],
@@ -1283,7 +1283,7 @@
}
],
"default": null,
"description": "Preferred backend for storing CLI auth credentials. file (default): Use a file in the Codex home directory. keyring: Use an OS-specific keyring service. auto: Use the keyring if available, otherwise use a file."
"description": "Preferred backend for storing CLI auth credentials. file: Use a file in the Codex home directory. keyring (default): Use an OS-specific keyring service. auto: Use the keyring if available, otherwise use a file."
},
"compact_prompt": {
"description": "Compact prompt used for history compaction.",
@@ -1514,7 +1514,7 @@
}
],
"default": null,
"description": "Preferred backend for storing MCP OAuth credentials. keyring: Use an OS-specific keyring service. https://github.com/openai/codex/blob/main/codex-rs/rmcp-client/src/oauth.rs#L2 file: Use a file in the Codex home directory. auto (default): Use the OS-specific keyring service if available, otherwise use a file."
"description": "Preferred backend for storing MCP OAuth credentials. keyring (default): Use an OS-specific keyring service. https://github.com/openai/codex/blob/main/codex-rs/rmcp-client/src/oauth.rs#L2 file: Use a file in the Codex home directory. auto: Use the OS-specific keyring service if available, otherwise use a file."
},
"mcp_servers": {
"additionalProperties": {

View File

@@ -29,10 +29,10 @@ use once_cell::sync::Lazy;
#[derive(Debug, Default, Copy, Clone, PartialEq, Eq, Serialize, Deserialize, JsonSchema)]
#[serde(rename_all = "lowercase")]
pub enum AuthCredentialsStoreMode {
#[default]
/// Persist credentials in CODEX_HOME/auth.json.
File,
/// Persist credentials in the keyring. Fail if unavailable.
#[default]
Keyring,
/// Use keyring when available; otherwise, fall back to a file in CODEX_HOME.
Auto,

View File

@@ -261,8 +261,8 @@ pub struct Config {
pub cwd: PathBuf,
/// Preferred store for CLI auth credentials.
/// file (default): Use a file in the Codex home directory.
/// keyring: Use an OS-specific keyring service.
/// file: Use a file in the Codex home directory.
/// keyring (default): Use an OS-specific keyring service.
/// auto: Use the OS-specific keyring service if available, otherwise use a file.
pub cli_auth_credentials_store_mode: AuthCredentialsStoreMode,
@@ -270,12 +270,12 @@ pub struct Config {
pub mcp_servers: Constrained<HashMap<String, McpServerConfig>>,
/// Preferred store for MCP OAuth credentials.
/// keyring: Use an OS-specific keyring service.
/// keyring (default): Use an OS-specific keyring service.
/// Credentials stored in the keyring will only be readable by Codex unless the user explicitly grants access via OS-level keyring access.
/// https://github.com/openai/codex/blob/main/codex-rs/rmcp-client/src/oauth.rs#L2
/// file: CODEX_HOME/.credentials.json
/// This file will be readable to Codex and other applications running as the same user.
/// auto (default): keyring if available, otherwise file.
/// auto: keyring if available, otherwise file.
pub mcp_oauth_credentials_store_mode: OAuthCredentialsStoreMode,
/// Optional fixed port to use for the local HTTP callback server used during MCP OAuth login.
@@ -923,8 +923,8 @@ pub struct ConfigToml {
pub forced_login_method: Option<ForcedLoginMethod>,
/// Preferred backend for storing CLI auth credentials.
/// file (default): Use a file in the Codex home directory.
/// keyring: Use an OS-specific keyring service.
/// file: Use a file in the Codex home directory.
/// keyring (default): Use an OS-specific keyring service.
/// auto: Use the keyring if available, otherwise use a file.
#[serde(default)]
pub cli_auth_credentials_store: Option<AuthCredentialsStoreMode>,
@@ -936,10 +936,10 @@ pub struct ConfigToml {
pub mcp_servers: HashMap<String, McpServerConfig>,
/// Preferred backend for storing MCP OAuth credentials.
/// keyring: Use an OS-specific keyring service.
/// keyring (default): Use an OS-specific keyring service.
/// https://github.com/openai/codex/blob/main/codex-rs/rmcp-client/src/oauth.rs#L2
/// file: Use a file in the Codex home directory.
/// auto (default): Use the OS-specific keyring service if available, otherwise use a file.
/// auto: Use the OS-specific keyring service if available, otherwise use a file.
#[serde(default)]
pub mcp_oauth_credentials_store: Option<OAuthCredentialsStoreMode>,
@@ -2465,10 +2465,9 @@ trust_level = "trusted"
}
#[test]
fn config_defaults_to_file_cli_auth_store_mode() -> std::io::Result<()> {
fn config_defaults_to_keyring_cli_auth_store_mode() -> std::io::Result<()> {
let codex_home = TempDir::new()?;
let cfg = ConfigToml::default();
let config = Config::load_from_base_config_with_overrides(
cfg,
ConfigOverrides::default(),
@@ -2477,7 +2476,7 @@ trust_level = "trusted"
assert_eq!(
config.cli_auth_credentials_store_mode,
AuthCredentialsStoreMode::File,
AuthCredentialsStoreMode::Keyring,
);
Ok(())
@@ -2506,7 +2505,7 @@ trust_level = "trusted"
}
#[test]
fn config_defaults_to_auto_oauth_store_mode() -> std::io::Result<()> {
fn config_defaults_to_keyring_oauth_store_mode() -> std::io::Result<()> {
let codex_home = TempDir::new()?;
let cfg = ConfigToml::default();
@@ -2518,7 +2517,7 @@ trust_level = "trusted"
assert_eq!(
config.mcp_oauth_credentials_store_mode,
OAuthCredentialsStoreMode::Auto,
OAuthCredentialsStoreMode::Keyring,
);
Ok(())

View File

@@ -69,12 +69,13 @@ pub struct StoredOAuthTokens {
pub enum OAuthCredentialsStoreMode {
/// `Keyring` when available; otherwise, `File`.
/// Credentials stored in the keyring will only be readable by Codex unless the user explicitly grants access via OS-level keyring access.
#[default]
Auto,
/// CODEX_HOME/.credentials.json
/// This file will be readable to Codex and other applications running as the same user.
File,
/// Keyring when available, otherwise fail.
/// This is the default storage mode.
#[default]
Keyring,
}