Skip to content

feat: add CLI device authentication - #154

Merged
jefft72 merged 3 commits into
mainfrom
codex/cli-auth-20260829
Aug 30, 2026
Merged

jefft72 merged 3 commits into
mainfrom
codex/cli-auth-20260829

Conversation

@jefft72

@jefft72 jefft72 commented Aug 29, 2026

Copy link
Copy Markdown
Contributor

Summary

Adds Diffex account authentication to the CLI through diffex auth login, diffex auth status, and diffex auth logout.
The login flow uses device authorization and stores the resulting session in the operating system keychain without exposing tokens in terminal output.

Reasoning

This milestone connects the CLI to Diffex account identity without prematurely coupling authentication to hosted cloud operations.
Credentials must remain out of plaintext files and terminal output, while the browser handoff, polling behavior, refresh rotation, and logout path need predictable failure handling.

Changes

  • Adds parsing and dispatch for Diffex account login, status, and logout commands
  • Implements device authorization startup and bounded polling with pending, slowdown, retry, and expiry handling
  • Refreshes expiring sessions and rotates refresh tokens before reporting authenticated status
  • Removes local credentials even when remote logout confirmation is unavailable
  • Stores versioned account sessions in the operating system keychain without a plaintext fallback
  • Loads native keychain support only when an account command accesses credentials
  • Reports safe account-specific errors when keychain support is unavailable
  • Requires HTTPS verification URLs for deployed APIs and limits HTTP URLs to local development
  • Rejects verification URLs containing credentials or mismatched completion origins
  • Adds the pinned keyring dependency and updates generated dependency locks
  • Adds regression coverage for polling, refresh, logout, keyring storage, and unsafe verification responses

Testing

  • npm exec -- vitest run packages/coding-agent/test/account-auth-storage.test.ts packages/coding-agent/test/account-auth-command.test.ts
  • npm run check
  • npm run build

Add WorkOS device authorization commands for login, status, and logout with bounded polling, refresh-token rotation, secret-safe output, and native OS keyring storage without a plaintext fallback. Include exact native dependencies, generated install locks, and focused behavior and storage tests.
Load native keyring support only when account credentials are accessed and report safe failures. Restrict verification URLs to trusted transports and same-origin completion links before opening a browser.
@jefft72 jefft72 added enhancement New feature or request coding-agent labels Aug 29, 2026
@jefft72
jefft72 requested a review from Pepps233 August 29, 2026 16:32

@Pepps233 Pepps233 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove existing auth routings through diffex auth login, diffex auth status, and diffex auth logout. Instead, route auth using existing slash commands /login and /logout because they are the two main interfaces for interacting with model auths.

Remove the standalone account login, status, and logout routes, and integrate secure Diffex device sign-in and sign-out into the existing /login and /logout flows while preserving provider credential management.
@jefft72
jefft72 merged commit e326056 into main Aug 30, 2026
0 of 2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

coding-agent enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants