M1/F1: Kimi Code OAuth device-code flow
Replace the xAI OAuth stack with the Kimi device authorization grant:
- kimi_oauth.rs wire layer (device_authorization + token poll + refresh
against kigi_env::oauth_host(); client_id per PRD; retryable statuses
429/5xx with backoff; expired_token restarts authorization)
- X-Msh-Device-{Name,Model,Id} headers; device_id minted uuid4-hex at
~/.kigi/device_id (0600)
- Storage: system keyring service `kigi`, entry `oauth/kimi-code`
(macOS/Windows native backends), atomic-file fallback under ~/.kigi;
official client's keyring/~/.kimi never touched
- Refresh manager: 60s tick, threshold max(300, expires_in*0.5),
401-tombstone keyed by rejected refresh token with 300s cooldown and
rotation auto-clear, cross-process lock with sibling-adoption
triple-check, sleep/wake forced refresh
- Deleted xAI machinery: enterprise OIDC (PKCE/JWKS/teams), devbox login,
external auth provider, JWT tier gating + subscription paywall stack,
X-XAI-Token-Auth marker headers, ZDR gates, /user enrichment
- kigi login / TUI /login both drive the device flow; login-host display
now derives from kigi_env::oauth_host()
- 264 auth unit/wiremock tests; live contract probe of
auth.kimi.com/api/oauth/device_authorization matches the wire shapes
Gates: check/clippy --all-targets clean, fmt, deny ok, kigi-shell lib
5131 tests green.
This commit is contained in:
@@ -19,29 +19,8 @@ pub enum Command {
|
||||
Leader(LeaderMgmtArgs),
|
||||
/// Sign out and clear cached credentials
|
||||
Logout,
|
||||
/// Sign in
|
||||
Login {
|
||||
/// Ignored (kept for backwards compatibility). OAuth2 is now the only auth method.
|
||||
#[arg(long, hide = true)]
|
||||
legacy: bool,
|
||||
/// Use Grok OAuth via auth.x.ai.
|
||||
#[arg(long = "oauth", alias = "oidc", conflicts_with_all = ["device_auth"])]
|
||||
oauth: bool,
|
||||
/// Use device-code authentication for headless/remote environments.
|
||||
#[arg(
|
||||
long = "device-auth",
|
||||
visible_alias = "device-code",
|
||||
conflicts_with_all = ["oauth"]
|
||||
)]
|
||||
device_auth: bool,
|
||||
/// Authenticate for remote development environments (hidden).
|
||||
///
|
||||
/// Field is always present so match arms stay feature-unification-safe
|
||||
/// across Bazel/cargo graphs; clap only registers `--devbox` when
|
||||
/// `devbox-login` is enabled (`arg(skip)` otherwise → always false).
|
||||
#[arg(skip)]
|
||||
devbox: bool,
|
||||
},
|
||||
/// Sign in with your Kimi Code subscription (device-code flow)
|
||||
Login,
|
||||
/// Manage MCP server configurations
|
||||
Mcp(crate::mcp_cmd::McpArgs),
|
||||
/// Manage plugins
|
||||
|
||||
Reference in New Issue
Block a user